FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fixtures: fix parametrization losing (static) transitive dependencies from overridden fixtures by bluetech · Pull Request #14369 · pytest-dev/pytest · GitHub

fixtures: fix parametrization losing (static) transitive dependencies from overridden fixtures - #14369

Merged
bluetech merged 6 commits into
pytest-dev:mainfrom
bluetech:fixture-override-with-parametrization
May 3, 2026
Merged

fixtures: fix parametrization losing (static) transitive dependencies from overridden fixtures#14369
bluetech merged 6 commits into
pytest-dev:mainfrom
bluetech:fixture-override-with-parametrization

Conversation

bluetech commented Apr 8, 2026

Copy link
Copy Markdown
Member

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_tree use the same underlying code as the already-fixed getfixtureclosure.

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.

Sylvain MARIE and others added 6 commits April 8, 2026 12:23
…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.
psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Apr 8, 2026
bluetech merged commit 206b971 into pytest-dev:main May 3, 2026
33 checks passed
bluetech deleted the fixture-override-with-parametrization branch May 3, 2026 09:06
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

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] prune_dependency_tree's behaviour conflicts with the latest improvements in getfixtureclosure (pytest 9.x)

1 participant


Back | FazBrowse Home | New Git URL