Repository navigation
[PR #14645/a933cf5d backport][9.1.x] fix: deduplicate Directory nodes on re-collection to preserve fixture identity (#14635) - #14968
Merged
RonnyPfannschmidt merged 1 commit intoSep 6, 2026
Conversation
Merged
5 tasks done
RonnyPfannschmidt
approved these changes
Sep 6, 2026
RonnyPfannschmidt
deleted the
patchback/backports/9.1.x/a933cf5de4d64192d1d588a851ca4e76eec71efc/pr-14645
branch
September 6, 2026 07:35
This was referenced Sep 6, 2026
cya
pushed a commit
to cya/TaskQ
that referenced
this pull request
Sep 19, 2026
…erleaved args resolve (issue AZX-PBC-OSS#273) pytest 9.1.1 drops a nested conftest's fixtures for a test file REVISITED non-adjacently in the argument list: pytest tests/web_admin/test_factory.py tests/test_zero_value_convention.py tests/web_admin/test_queues.py errored on every test in the revisited file with "fixture 'stub_pool' not found" while the adjacent ordering passed. Upstream pytest-dev/pytest#14971: collection builds a second Directory node for the revisited directory and fixture registration matches by node identity, so fixtures registered under the first instance are invisible to items collected under the second. Move the web_admin fixtures out of tests/web_admin/conftest.py into tests/web_admin/_fixtures.py and register them from tests/conftest.py, which loads for every test regardless of argument order. The autouse env fixture is path-gated to tests/web_admin/ so its mutations stay scoped to the suite that had them before. Root-level guard pins both orderings plus an upstream-behavior probe version-gated on the pytest-dev/pytest#14968 backport.
This was referenced Sep 21, 2026
rcbevans
added a commit
to AZX-PBC-OSS/TaskQ
that referenced
this pull request
Sep 23, 2026
…ping (#447) * test: the interleaved-args probe runs unconditionally instead of skipping pytest-dev/pytest#14968 (the 9.1.x backport of the pytest-dev/pytest#14971 fix) is still unreleased: PyPI's newest pytest is 9.1.1, so there is no version to adopt and the upstream-behavior probe version-gated on (9, 2, 0) skipped on every board, verifying nothing. The upstream bug is specific to fixtures defined in a nested conftest.py (re-collection of the revisited directory builds a second Directory node and fixture registration matches by node identity). Fixtures that do not ride a re-collected Directory node - the root conftest.py and each test module's own fixtures - resolve under the same interleaving; verified against 9.1.1 and 8.4.2 scratch projects, with the nested-conftest negative control erroring on 9.1.1 exactly as upstream reports. Replace the skip with a probe of that scenario: root conftest fixture plus per-module fixtures, asserted under both argument orderings. The nested conftest shape stays covered at the repo level by the two guards (web_admin fixtures registered from tests/conftest.py). A nested-conftest variant of the probe can be added once the pin moves past the release that ships the backport. * ci: board the queue * ci: re-board --------- Co-authored-by: rich <rich@local>
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.
This is a backport of PR #14645 as merged into main (a933cf5).
Summary
Fixes #14635.
When
Sessionre-collects a parent Directory (due tohandle_dupes=Falsefor file CLI args), fresh child nodes were created. Since fixture registration uses node identity for matching (_matchfactorieschecksfixturedef.node in parent_nodes), the new Directory children didn't match fixtures registered with the original instances.This caused fixture closure computation to fail for tests collected after unrelated paths, because the conftest fixtures were registered with a now-orphaned Directory node instance.
Root cause:
_collect_one_nodewithhandle_dupes=Falsecallscollect()on the parent Directory, which creates brand-new child Directory/Package instances. The_collection_cacheis then updated with these new children. Later collection paths that look up cached children find different node objects than the ones conftest fixtures were registered with.Fix: After re-collection, replace any freshly-created Directory children with the previously-seen instances for the same path. Module/File nodes are still recreated to preserve
--keep-duplicatessemantics (which needs fresh test items).Test plan
test_fixture_closure_order_independence_with_parametrizethat reproduces the exact scenario from Error collecting tests on 9.1.1 - fixtures not found when a parent directory appears multiple times in a argument list #14635TestOverlappingCollectionArguments::test_complex_combined_handling(which exercises--keep-duplicateswith overlapping file/dir args) passes--keep-duplicates file.py file.pystill collects the file twiceMade with Cursor