mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-20 21:25:14 +02:00
fix: do not monkeypatch attributes on Starlette State in tests
pytest 9.2 reads the old value of a monkeypatched attribute from the instance __dict__. Starlette State keeps attributes in an internal dict, so the old value looks unset and the teardown deletes the attribute for the rest of the test session. The first test that touches app.state.exiting passes but removes it, and every later monkeypatch.setattr on it fails with AttributeError. Use plain assignments instead.
This commit is contained in:
3 files changed
+50
-29
No files matched your search
@@ -640,7 +640,10 @@ async def test_connect_notification_poison_frame_autoreconnects(compute, monkeyp
|
||||
# would execute module-level from-imports while the autouse fixture's
|
||||
# monkeypatches are active, freezing patched objects into namespaces)
|
||||
monkeypatch.delattr(sys, "_called_from_test", raising=False)
|
||||
monkeypatch.setattr(gns3_app.state, "exiting", False)
|
||||
# plain assignment instead of monkeypatch.setattr: Starlette's State keeps
|
||||
# attributes in an internal dict, so pytest 9.2+ teardown would delete the
|
||||
# attribute for the rest of the test session
|
||||
gns3_app.state.exiting = False
|
||||
|
||||
async def fake_connect():
|
||||
compute._reconnect_attempted = True
|
||||
|
||||
Reference in new issue
Block a user