Skip to content

Clarify scoped fixture rerun support - #371

Merged
icemac merged 4 commits into
pytest-dev:masterfrom
LouisDeconinck:docs/fixture-support-183
Sep 17, 2026
Merged

icemac merged 4 commits into
pytest-dev:masterfrom
LouisDeconinck:docs/fixture-support-183

Conversation

@LouisDeconinck

Copy link
Copy Markdown
Contributor

Fixes #183.

Clarify the currently supported fixture behavior in the README: setup failures and setup_class failures are rerun for class-, module-, package-, and session-scoped fixtures, while successful higher-scoped fixtures remain cached across a rerun and are torn down once afterward.

Add a package-scoped setup regression test and a towncrier documentation fragment.

Checks:

  • PYTHONPATH=src python3 -m pytest -q (227 passed, 9 skipped)
  • uvx --from pre-commit pre-commit run --files README.rst tests/test_pytest_rerunfailures.py changes/183.doc.rst
  • git diff --check

Comment thread tests/test_pytest_rerunfailures.py

@icemac icemac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. The new text is accurate (I verified the session-, module- and package-scope behaviour empirically), but a few things need adjusting before merge.

Comment created by Claude

Comment thread README.rst Outdated
Comment thread README.rst Outdated
Comment thread tests/test_pytest_rerunfailures.py
Comment thread changes/183.doc.rst Outdated
@LouisDeconinck

Copy link
Copy Markdown
Contributor Author

Addressed the latest review round:

  • README.rst: moved the "Fixture support" paragraph after the --reruns-delay/--reruns-delay-backoff-factor docs and gave it a --- heading, so it is a top-level section instead of a ~~~~~ subsection of "Re-run all failures".
  • README.rst + docs/quickstart.rst: wrapped the section in .. START-FIXTURES / .. END-FIXTURES markers and included it from the quickstart page via start-after/end-before, matching the existing fragment includes. Verified with sphinx-build: it renders as its own section on the quickstart page.
  • tests/test_pytest_rerunfailures.py: the package-scoped fixture now lives in pkg/conftest.py and is used by two test modules (pkg/test_foo.py, pkg/test_bar.py). The test asserts the fixture sets up twice in total (failed attempt + rerun) and is torn down once (["setup", "setup", "teardown"]); it fails under module scope, confirming it exercises package scope. Verified: 2 passed, 1 rerun.
  • changes/183.doc.rst: unwrapped to a single line.

@icemac
icemac enabled auto-merge (squash) September 17, 2026 06:57

@icemac icemac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for this PR. 😃

@icemac
icemac merged commit a7eb9cf into pytest-dev:master Sep 17, 2026
45 checks passed
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.

Clarification of class/module/package level fixture support

3 participants