Open The-Compiler opened 1 month ago
Let's forbid getfixturevalue to trigger setup after the fixture was yielded
As in, make it error out explicitly if we're in the teardown phase and request a fixture that has not already been requested before? Makes sense I'd say.
Oh, though I'm not sure how much existing usage it'd break - evidently there are cases where this kind of thing still seems to work out currently? Maybe we should deprecate it first or something (plus improve the error message if it happens to hard-fail)?
We can start with deprecating and replace it with a exception later
With 8.3.3 (as well as the current
main
, f373974707f57a0b28d12563e4d03c7cd54c70d9), something likeresults in a rather confusing internal
AssertionError
from pytest:which is here:
https://github.com/pytest-dev/pytest/blob/d0f136fe64f9374f18a04562305b178fb380d1ec/src/_pytest/runner.py#L519-L527
This seems similar to what has been reported (and improved) by @petebman here:
9984
9990
and indeed, also requesting
tmp_path
from the test (afterfixt
, so it's torn down first) leads to a much better error message:From what I can gather, what happens here instead is:
tmp_path
fixt
requests it during teardowntmp_path
with the current test nodeAssertionError
In the actual context we saw this in qutebrowser, this was made even more difficult to debug:
__tracebackhide__
in my code?!) decided to just show:without a full traceback.