Restore precedence of indirect parametrize over fixture params#14593
Closed
KirtiRamchandani wants to merge 1 commit into
Closed
Restore precedence of indirect parametrize over fixture params#14593KirtiRamchandani wants to merge 1 commit into
KirtiRamchandani wants to merge 1 commit into
Conversation
Fixes pytest-dev#14591 Commit d56b1af removed a special case in pytest_generate_tests that skipped applying fixture params when the test already parametrizes the same argument via @pytest.mark.parametrize. That removal caused duplicate parametrization errors when overriding a fixture's params with indirect parametrize marks. Restore the precedence check and add a regression test.
Member
|
Thanks, will do it through #14597 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14591
Problem
In pytest 9.1.0, using
@pytest.mark.parametrize(..., indirect=True)to override the parameters of a fixture that already hasparams=[...]raisesduplicate parametrization of {fixture_name}during collection. This worked in previous releases.The regression was introduced by d56b1af, which removed a special case in
pytest_generate_teststhat skipped applying fixture params when the test already parametrizes the same argument.Fix
Restore the precedence check in
FixtureManager.pytest_generate_tests: when a test has aparametrizemark for an argument name, do not also apply that fixture'sparamsviapytest_generate_tests.Test plan
test_indirect_parametrize_overrides_fixture_paramsbased on the minimal reproducer from the issuetesting/python/fixtures.py::test_fixture_param_shadowingstill passes