Skip to content

Conversation

@bluetech
Copy link
Member

@bluetech bluetech commented Oct 6, 2025

Continuation of #13774.

The previous fix was a minimal change to make the existing code at least consider fixtures overrides, and handles the common case (direct override chains), but still wasn't correct, as it didn't handle override chains involving an intermediary (not the overridden) fixture.

To make this work, the algorithm needs to change. Now instead of a simple breadth-first search, we do a depth-first search, which more closely simulates the runtime behavior, and allows us the to check the "stack" of fixtures so we can use the correct fixture index (depth in the override chain).

This is more expensive but should be OK.

Refs #13773.

Explicitly test a couple more scenarios. One of the tests doesn't
currently pass so marked xfail.
Continuation of 72ae3db.

The previous fix was a minimal change to make the existing code at least
consider fixtures overrides, and handles the common case (direct
override chains), but still wasn't correct, as it didn't handle
override chains involving an intermediary (not the overridden) fixture.

To make this work, the algorithm needs to change. Now instead of a
simple breadth-first search, we do a depth-first search, which more
closely simulates the runtime behavior, and allows us the to check the
"stack" of fixtures so we can use the correct fixture index (depth in
the override chain).

This is more expensive but should be OK.

Refs pytest-dev#13773.
@bluetech
Copy link
Member Author

Going to merge this, because it finishes the work in #13774 for pytest 9.0, and I have some work planned which depends on it.

I also noticed that in #11234 @sadra-barikbin had the same idea (changing fixturemanager::getfixtureclosure algo from BFS to DFS), though didn't get to implement it. So must have some merit :)

@bluetech bluetech merged commit 37acc4f into pytest-dev:main Oct 10, 2025
33 checks passed
@bluetech bluetech deleted the fixtures-closure-visibility-3 branch October 10, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant