-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fixture teardown order incorrect when using getfixturevalue #9151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Observations:
|
I'm not sure but maybe the @pytest.fixture(scope="session")
def b(request):
- logging.info("B: setup")
request.getfixturevalue("a")
+ logging.info("B: setup")
yield None
logging.info("B: cleanup") |
closing as behaving as intended even if non-intuitive your quirky roundabout setup triggers the setup of B before a, then A gets requested by b dynamically this in the end enforces that A is added to the setup state after b, and thus has to be taken down before b |
OK, thanks for clarifying. Do you think this is something that should be called out explicitly in the documentation? Here, is the text:
Then here is the text:
Neither of these mention It sounds like that is not, and is not intended to be, the case. Which piece of logic is incorrect? Is it that I see there is this text on the reference for
However I interpreted that to mean that you couldn’t call I’m happy to put together a PR against the documentation if you think it’s worthwhile, once I understand what meaning was intended (I don’t want to overreach and write documentation that promises more or less than was intended). |
I'll have to get back at his later, I'll have to make time to dig into exact terminology |
I am running Pytest 6.2.5.
Consider the following test file:
When run with
py.test -s -v -v --log-level=info --log-cli-level=info
it produces the following output:This is wrong: fixture
B
depends on fixtureA
viarequest.getfixturevalue
, and therefore fixtureB
should be cleaned up before fixtureA
.This can’t be a duplicate of GH-1895 because that ticket was fixed in 4.4.0, and this still happens in 6.2.5. I don’t think it’s a duplicate of GH-6512 either, because that ticket says that 5.3.2 was OK and 5.3.3 was broken; however, my issue posted here shows up in both 5.3.2 and also 5.3.3.
The text was updated successfully, but these errors were encountered: