fixtures: fix parametrization losing (static) transitive dependencies from overridden fixtures#14369
Open
bluetech wants to merge 6 commits intopytest-dev:mainfrom
Open
fixtures: fix parametrization losing (static) transitive dependencies from overridden fixtures#14369bluetech wants to merge 6 commits intopytest-dev:mainfrom
bluetech wants to merge 6 commits intopytest-dev:mainfrom
Conversation
…th overrides and parametrization Based on existing tests, just adding the parametrization. Refs pytest-dev#14248.
…n_ordering No functional changes, just making it easier to follow.
…es without monkeypatching Seems better to avoid this monkeypatch-pytest-to-smuggle-info-out-of-pytester pattern.
… from overridden fixtures As the xfail'ed test `test_fixture_closure_with_overrides_and_parametrization` demonstrates, adding any direct parametrization causes the statically computed fixture closure to omit transitive dependencies from overridden (but still requested) fixtures. (The dynamic algorithm does get it right). The `prune_dependency_tree()` function did not account for overridden fixtures properly (only checked `-1`). Make it share the core recursive DFS traversal used by `getfixtureclosure()`, which already fixed a similar problem (pytest-dev#13789). An alternative solution is to replace `prune_dependency_tree` wholesale with another call to `getfixtureclosure`, as proposed in PR pytest-dev#11243, however it's somewhat harder to get working, so let's go with this solution for now. Fix pytest-dev#14248
Didn't include this in the previous commit, in case it causes regressions.
(I am talking here about `names_closure`/`fixturenames`.) Before 72ae3db, the static traversal order was BFS (unlike the dynamic order which is DFS). So it was natural that `initialnames` was always at the beginning of the closure, since it consists the initial working set. When we changed to DFS, we kept this. But it's a bit weird, now the initialnames are in BFS, but all transitive dependencies are in DFS. Remove this special case, making both the static and dynamic order fully DFS.
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 PR fixes #14248.
The 1st commit adds the xfailed test from @smarie in the issue.
The 2nd and 3rd commits do some related test cleanup.
The 4th commit is the actual fix. Basically, just making
prune_dependency_treeuse the same underlying code as the already-fixedgetfixtureclosure.The 5th commit is some optimizations that I split to make the previous commit minimal.
The 6th commit is a bit of a consistency fix and optimization, changing the static fixture order to fully DFS like the dynamic one.