From 1d891cc07052d22b11bda000cb8b729049f2c2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Sat, 10 Oct 2026 16:31:06 +0200 Subject: [PATCH] test(import): undo monkeypatches before cleanup deletes buckets Fixtures tear down in reverse setup order. The two rollback tests list monkeypatch before cleanup, so cleanup ran while delete_bucket was still patched to fail, and leaked test-import-rb-a/-rb-b/-rb-c into the session's testing DB. test_server.py::test_buckets then saw 4 buckets instead of 1, failing the bundle's integration tests on every Qt build. --- tests/test_import.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_import.py b/tests/test_import.py index 4ebc2aa..0598f1d 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -25,9 +25,13 @@ def _bucket(bucket_id, events=None): @pytest.fixture() -def cleanup(flask_client): +def cleanup(flask_client, monkeypatch): ids = [] yield ids + # Fixtures tear down in reverse setup order, so a test listing + # `monkeypatch` before `cleanup` still has e.g. a failing delete_bucket + # patched here; undo first so cleanup can't leak buckets into later tests. + monkeypatch.undo() buckets = flask_client.get("/api/0/buckets/").json for bucket_id in ids: if bucket_id in buckets: