fixtures: deprecate calling request.getfixturevalue() during teardown#14295
fixtures: deprecate calling request.getfixturevalue() during teardown#14295bluetech wants to merge 2 commits intopytest-dev:mainfrom
Conversation
…ssage In this case let's just show the test function.
on a fixture that hasn't already been requested. Fix pytest-dev#12882.
themavik
left a comment
There was a problem hiding this comment.
Deprecates calling request.getfixturevalue() during teardown for fixtures not already requested. Addresses #12882.
Done well: Clear deprecation docs explaining why (teardown runs during scope unwind, lookup order is brittle). Good test coverage: previously-requested OK, new fixture warns, inactive fixture errors. is_node_active is a clean abstraction. _raise_teardown_lookup_error gives a helpful message.
Concern: In formatrepr, the change from assert self.msg is None or self.fixturestack to if msg is not None and len(stack) > 1 removes the assert. The old assert guarded against empty fixturestack with non-None msg. The new logic avoids the crash by not using stack[:-1] when len(stack) <= 1. Worth a quick check that no code path can hit msg is not None with empty fixturestack—if so, the formatrepr output might be odd. Otherwise looks good.
on a fixture that hasn't already been requested.
Fix #12882.
The first commit is needed for the $subject change.