Assignment expression changes value of variable in unrelated test case #11239
Labels
topic: rewrite
related to the assertion rewrite mechanism
type: regression
indicates a problem that was introduced in a release which was working previously
The
assert
rewriting intest2
effects the result oftest_1
just because both asserts are using the same identifierstate
.Tested with pytest
7.3.2
and7.4.0
.I bisected the issue to #11041. From what I can tell, the assertion rewriter doesn't track the current context. Thus
state
intest_1
is replaced withdb.get("x")
fromtest_2
even though they are in separate functions.This behavior can be quite surprising as a user typically doesn't expect test cases with purely local variables and without side effects to influence one another.
As there is another regression (#11115) with this PR already, maybe it would be best to revert it?
/CC @aless10
The text was updated successfully, but these errors were encountered: