Docs: clarify conftest usage and fixture import pitfalls#14128
Open
Dooopinder wants to merge 7 commits intopytest-dev:mainfrom
Open
Docs: clarify conftest usage and fixture import pitfalls#14128Dooopinder wants to merge 7 commits intopytest-dev:mainfrom
Dooopinder wants to merge 7 commits intopytest-dev:mainfrom
Conversation
for more information, see https://pre-commit.ci
bluetech
reviewed
Jan 18, 2026
Member
bluetech
left a comment
There was a problem hiding this comment.
Thanks for looking at this. Please see my comments.
Also pinging @The-Compiler who might want to review this (the issue discusses a bit larger reworking of the docs around this IIUC).
Contributor
Author
|
Thanks a lot for the detailed review! This makes sense — I’ll rework the text |
Contributor
Author
|
Hello @bluetech :) I’ve updated the text to integrate the notes into the main flow, clarified the wording, and addressed the type-annotation explanation. Please let me know if this looks better now. |
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.
Clarifies that fixture scope controls lifetime and caching, not visibility
Explicitly explains that fixture visibility depends on where it is defined (test module, conftest.py, or plugin)
Recommends conftest.py as the correct and supported way to share fixtures across multiple test modules
Adds a clear warning against importing fixtures from test files or conftest.py, which can cause duplicate registration and confusing behavior
Adds a simple rule of thumb: never import fixtures except for type annotations
Links readers to the reference documentation for deeper technical details
closes #13148