Open jgersti opened 9 months ago
Would love to see pytest-lazy-fixture become a part of core pytest since the existing outside solutions are not compatible with pytest 8.x (and not maintained) or missing functionality, it seems.
Previous discussion on the topic: #3244.
Now that pytest-lazy-fixture
is no longer being maintained (it seems), I definitely agree that this feature should be integrated into the core.
My hunch is that because it can be implemented directly in the internals, the implementation can be simpler than pytest-lazy-fixture itself.
Unfortunately it is not as simple. Both pytest-cases
and pytest-lazy-fixture
have bugs with transitive dependencies, because pytest-cases
explicitly and pytest-lazy-fixture
implicitly assume that the dependencies form a tree. In reality the dependencies from a DAG (directed acyclic graph) and if there is a diamond pattern in the transitive dependencies both plugins can break by either not loading a required fixture, loading too many fixtures, and/or using inappropriate parametrization.
As I tried to convey in the post above and the attached discussion, I think the first step should be fixing/refactoring the dependency calculation and internal depenency representation in pytest
itself, so so the dependency graph is explicitly known and it can be manipulated . There is a experimental branch where I implemented an algorithm to build the graph, but i realized quite fast that the current priority of autouse fixtures is difficult to replicate. I did take some notes which tests failed with some guesses as to why, but i am currently unable to find these.
This change more or less equates to ripping out most/all of the fixture dependency and replacing them.
Discussed in https://github.com/pytest-dev/pytest/discussions/11412