Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/15049.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
When :option:`--fixtures` or :option:`--fixtures-per-test` are used, the :hook:`pytest_collection` hook is now called to perform the collection.
Previously, these two modes performed the collection directly, bypassing the hook.

@nicoddemus nicoddemus Sep 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone reading this might wonder "where is the breaking change?", because it is non-obvious. Perhaps mention why this might break something, just to clarify the entry.

6 changes: 4 additions & 2 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,8 @@ def _get_fixtures_per_test(test: nodes.Item) -> Iterator[FixtureDef[object]]:
def _show_fixtures_per_test(config: Config, session: Session) -> None:
import _pytest.config

session.perform_collect()
config.hook.pytest_collection(session=session)

invocation_dir = config.invocation_params.dir
tw = _pytest.config.create_terminal_writer(config)
verbose = config.get_verbosity()
Expand Down Expand Up @@ -2505,7 +2506,8 @@ def showfixtures(config: Config) -> int | ExitCode:
def _showfixtures_main(config: Config, session: Session) -> None:
import _pytest.config

session.perform_collect()
config.hook.pytest_collection(session=session)

invocation_dir = config.invocation_params.dir
tw = _pytest.config.create_terminal_writer(config)
verbose = config.get_verbosity()
Expand Down