Closed
Description
There seems to be a regression in pytest version 7.3.x
when a walrus operator is used in an assert line.
Code:
import json
import pytest
def test_json_encoder():
assert (object:="foo") in json.dumps(object)
Fails the test with error:
UnboundLocalError: cannot access local variable 'object' where it is not associated with a value
in pytest version 7.3.x
, whereas with pytest version 7.2.x
it passes successfully. My Python version is 3.11
.
Looks like it has to do with PR #10758.