From 8a82379e5439ebff6f6e7b0aa584ffe445d9a22d Mon Sep 17 00:00:00 2001 From: Teknium Date: Sat, 28 Mar 2026 12:13:06 -0700 Subject: [PATCH] fix: patch nio mock in e2ee maintenance sync loop test The sync_loop now imports nio for SyncError checking (from PR #3280), so the test needs to inject a fake nio module via sys.modules. --- tests/gateway/test_matrix.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/gateway/test_matrix.py b/tests/gateway/test_matrix.py index a25a69cde73d..5a9879f60574 100644 --- a/tests/gateway/test_matrix.py +++ b/tests/gateway/test_matrix.py @@ -539,6 +539,9 @@ class TestMatrixE2EEMaintenance: adapter._encryption = True adapter._closing = False + class FakeSyncError: + pass + async def _sync_once(timeout=30000): adapter._closing = True return MagicMock() @@ -559,7 +562,11 @@ class TestMatrixE2EEMaintenance: adapter._client = fake_client - await adapter._sync_loop() + fake_nio = MagicMock() + fake_nio.SyncError = FakeSyncError + + with patch.dict("sys.modules", {"nio": fake_nio}): + await adapter._sync_loop() fake_client.sync.assert_awaited_once_with(timeout=30000) fake_client.send_to_device_messages.assert_awaited_once()