From 11f5c1ecf01665dfa82cfa558b0eaf275176c3f1 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Sun, 1 Mar 2026 05:28:55 -0800 Subject: [PATCH] fix(tests): use bare @pytest.mark.asyncio for hook emit tests Remove loop_scope="function" parameter from async test decorators in test_hooks.py. This matches the existing convention in the repo (test_telegram_documents.py) and avoids requiring pytest-asyncio 0.23+. All 144 new tests from PR #191 now pass. --- tests/gateway/test_hooks.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/gateway/test_hooks.py b/tests/gateway/test_hooks.py index 4f746dc0..3c011355 100644 --- a/tests/gateway/test_hooks.py +++ b/tests/gateway/test_hooks.py @@ -109,7 +109,7 @@ class TestDiscoverAndLoad: class TestEmit: - @pytest.mark.asyncio(loop_scope="function") + @pytest.mark.asyncio async def test_emit_calls_sync_handler(self, tmp_path): results = [] @@ -129,7 +129,7 @@ class TestEmit: await reg.emit("agent:start", {"test": True}) assert "agent:start" in results - @pytest.mark.asyncio(loop_scope="function") + @pytest.mark.asyncio async def test_emit_calls_async_handler(self, tmp_path): results = [] @@ -155,7 +155,7 @@ class TestEmit: await reg.emit("agent:end", {}) assert "agent:end" in results - @pytest.mark.asyncio(loop_scope="function") + @pytest.mark.asyncio async def test_wildcard_matching(self, tmp_path): results = [] @@ -174,13 +174,13 @@ class TestEmit: await reg.emit("command:reset", {}) assert "command:reset" in results - @pytest.mark.asyncio(loop_scope="function") + @pytest.mark.asyncio async def test_no_handlers_for_event(self, tmp_path): reg = HookRegistry() # Should not raise await reg.emit("unknown:event", {}) - @pytest.mark.asyncio(loop_scope="function") + @pytest.mark.asyncio async def test_handler_error_does_not_propagate(self, tmp_path): _create_hook(tmp_path, "bad-hook", '["agent:start"]', "def handle(event_type, context):\n" @@ -193,7 +193,7 @@ class TestEmit: # Should not raise even though handler throws await reg.emit("agent:start", {}) - @pytest.mark.asyncio(loop_scope="function") + @pytest.mark.asyncio async def test_emit_default_context(self, tmp_path): captured = []