[Rejected ai slop]fix: register conftest fixtures by nodeid for Directory nodes - #14965
Closed
dajiaohuang wants to merge 1 commit into
Closed
[Rejected ai slop]fix: register conftest fixtures by nodeid for Directory nodes#14965dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
Fixes pytest-dev#14964 Conftest fixtures are silently missing for files collected after a file argument from an ancestor directory (pytest 9.1.0+, regression from pytest-dev#14004). When registering an autouse fixture for a Directory node, also store it by nodeid string in _nodeid_autousenames. When looking up autouse fixtures, check the nodeid-keyed table for Directory nodes. Assisted-by: Claude Opus 4.6
Member
|
Absolutely minimal change that fixes the wrong thing in the wrong place No tests and no propper analysis was done |
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.
Summary
Fixes #14964
Conftest fixtures are silently missing for files collected after a file argument from an ancestor directory. This is a regression in pytest 9.1.0+ from #14004.
Root Cause
Since #14004, conftest fixtures are parsed and registered against the specific Directory NODE that collects the conftest's directory. When a file is passed directly (not via directory collection), pytest may re-collect the ancestor directory with fresh child node objects. The new node never receives the conftest's fixtures.
Solution
Modified
_register_fixture,_getautousenames, and_matchfactoriesinsrc/_pytest/fixtures.py:_nodeid_autousenamesAssisted-by: Claude Opus 4.6