From 0c3253a4859cde2ef4972310e2763a25a84c07c0 Mon Sep 17 00:00:00 2001 From: 0xbyt4 <35742124+0xbyt4@users.noreply.github.com> Date: Mon, 9 Mar 2026 00:20:19 +0300 Subject: [PATCH] fix: mock asyncio.run in mirror test to prevent event loop destruction asyncio.run() closes the event loop after execution, which breaks subsequent tests using asyncio.get_event_loop() (test_send_image_file). --- tests/cron/test_scheduler.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.py index 4a456727..6b817a28 100644 --- a/tests/cron/test_scheduler.py +++ b/tests/cron/test_scheduler.py @@ -54,11 +54,8 @@ class TestDeliverResultMirrorLogging: mock_cfg = MagicMock() mock_cfg.platforms = {Platform.TELEGRAM: pconfig} - async def fake_send(*args, **kwargs): - return None - with patch("gateway.config.load_gateway_config", return_value=mock_cfg), \ - patch("tools.send_message_tool._send_to_platform", new=fake_send), \ + patch("asyncio.run", return_value=None), \ patch("gateway.mirror.mirror_to_session", side_effect=ConnectionError("network down")): job = { "id": "test-job",