Skip to content

Exclude parametrize pseudo-fixtures from --fixtures-per-test#13883

Closed
FazeelUsmani wants to merge 1 commit intopytest-dev:mainfrom
FazeelUsmani:claude/fix-fixtures-per-test-parametrize-011CUrdsBdByTNUJuP3G3eix
Closed

Exclude parametrize pseudo-fixtures from --fixtures-per-test#13883
FazeelUsmani wants to merge 1 commit intopytest-dev:mainfrom
FazeelUsmani:claude/fix-fixtures-per-test-parametrize-011CUrdsBdByTNUJuP3G3eix

Conversation

@FazeelUsmani
Copy link
Contributor

Previously, pytest --fixtures-per-test would display parameter names from @pytest.mark.parametrize decorators as if they were real fixtures, showing them with "no docstring available" and pointing to internal pytest code (_pytest/python.py).

This fix uses the existing _get_direct_parametrize_args() function to identify and exclude these pseudo-fixtures from the --fixtures-per-test output, ensuring only actual user-defined fixtures are displayed.

Example

Before this fix:
------------------ fixtures used by test_example[1] ------------------- real_fixture -- test_file.py:3 A real fixture. x -- .../_pytest/python.py:1110 ← Should not appear no docstring available

After this fix:
------------------ fixtures used by test_example[1] ------------------- real_fixture -- test_file.py:3 A real fixture.

Changes

  • Modified _show_fixtures_per_test() in src/_pytest/fixtures.py to filter out parametrize arguments
  • Added regression test test_parametrize_pseudo_fixtures_excluded to verify pseudo-fixtures are excluded

Closes #11295


…ures-per-test

Previously, pytest --fixtures-per-test would display parameter names from
@pytest.mark.parametrize decorators as if they were real fixtures, showing
them with "no docstring available" and pointing to internal pytest code.

This fix uses the existing _get_direct_parametrize_args() function to
identify and exclude these pseudo-fixtures from the --fixtures-per-test
output, ensuring only actual user-defined fixtures are displayed.

Changes:
- Modified _show_fixtures_per_test() to filter out parametrize arguments
- Added regression test to verify pseudo-fixtures are excluded
@The-Compiler
Copy link
Member

There's #12129 already open for this (and linked in the issue) for what it's worth. On first sight, this seems a bit simpler, but I haven't looked into things in detail yet.

@FazeelUsmani
Copy link
Contributor Author

@The-Compiler I see. Let me close this PR.

@FazeelUsmani FazeelUsmani deleted the claude/fix-fixtures-per-test-parametrize-011CUrdsBdByTNUJuP3G3eix branch November 12, 2025 13:10
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.

--fixtures-per-test: Exclude parametrizing pseudo fixtures?

2 participants