Skip to content

Restore precedence of indirect parametrize over fixture params#14593

Closed
KirtiRamchandani wants to merge 1 commit into
pytest-dev:mainfrom
KirtiRamchandani:fix-indirect-parametrize-override-14591
Closed

Restore precedence of indirect parametrize over fixture params#14593
KirtiRamchandani wants to merge 1 commit into
pytest-dev:mainfrom
KirtiRamchandani:fix-indirect-parametrize-override-14591

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

Fixes #14591

Problem

In pytest 9.1.0, using @pytest.mark.parametrize(..., indirect=True) to override the parameters of a fixture that already has params=[...] raises duplicate 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_tests that 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 a parametrize mark for an argument name, do not also apply that fixture's params via pytest_generate_tests.

Test plan

  • Added test_indirect_parametrize_overrides_fixture_params based on the minimal reproducer from the issue
  • Verified testing/python/fixtures.py::test_fixture_param_shadowing still passes
  • Ran the fixtures test module (336 passed)

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.
@bluetech

Copy link
Copy Markdown
Member

Thanks, will do it through #14597

@bluetech bluetech closed this Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest 9.1.0 does not allow overriding fixture's parameters via @pytest.mark.parametrize(..., indirect=True) anymore

2 participants