test: standardize async tests on pytest-asyncio auto mode (#338)
* chore: add pytest-asyncio in auto mode * test: migrate channel and stream tests to native async Convert run_async() wrapper tests to plain 'async def test_*' under pytest-asyncio auto mode. collect_events() in stream_v3_fakes becomes a coroutine awaited at every call site. * test: migrate command and model/middleware tests to native async Convert run_async() wrappers (import, alias, and fixture forms) to plain 'async def test_*'. Multi-call tests merge onto one loop as sequential awaits; none asserted on loop identity. * test: migrate TUI, notifier, gateway, and session tests to native async TUI/notifier/gateway files convert run_async wrappers to plain async tests. test_sessions.py's unittest.TestCase classes move to unittest.IsolatedAsyncioTestCase (pytest-asyncio does not await async methods on plain TestCase; converting blindly would have made ~70 tests silently vacuous). Its setUpClass keeps a one-shot asyncio.run() since IsolatedAsyncioTestCase has no async class-level hook. TestLoadingWidget in test_tui_widgets.py drops its TestCase base for the same reason. * test: replace direct asyncio.run() calls with native async tests Convert tests that called asyncio.run() (directly or via a local _run helper) to plain 'async def test_*'; delete the local helpers. * test: drop undeclared anyio markers and delete run_async helper The @pytest.mark.anyio tests relied on anyio being a transitive dep of httpx; auto-mode pytest-asyncio collects them natively. run_async() and its fixture are unreferenced after the migration, so remove them — pytest-asyncio's per-test loop teardown covers the pending-task cancellation the helper existed for (verified: full suite runs with no 'Event loop is closed' errors or destroyed-task warnings).
This commit is contained in:
@@ -2,11 +2,9 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from tests.conftest import run_async as _run
|
||||
|
||||
|
||||
class TestCurrentCommand:
|
||||
def test_prints_thread_workspace_and_memory(self):
|
||||
async def test_prints_thread_workspace_and_memory(self):
|
||||
from EvoScientist.commands.base import CommandContext
|
||||
from EvoScientist.commands.implementation.general import CurrentCommand
|
||||
|
||||
@@ -17,14 +15,14 @@ class TestCurrentCommand:
|
||||
ui=ui,
|
||||
workspace_dir="/tmp/ws",
|
||||
)
|
||||
_run(CurrentCommand().execute(ctx, []))
|
||||
await CurrentCommand().execute(ctx, [])
|
||||
# Three append_system calls: Thread, Workspace, Memory dir.
|
||||
calls = [c.args[0] for c in ui.append_system.call_args_list]
|
||||
assert any("Thread: abc123" in s for s in calls)
|
||||
assert any("Workspace:" in s for s in calls)
|
||||
assert any("Memory dir:" in s for s in calls)
|
||||
|
||||
def test_skips_workspace_when_none(self):
|
||||
async def test_skips_workspace_when_none(self):
|
||||
from EvoScientist.commands.base import CommandContext
|
||||
from EvoScientist.commands.implementation.general import CurrentCommand
|
||||
|
||||
@@ -35,7 +33,7 @@ class TestCurrentCommand:
|
||||
ui=ui,
|
||||
workspace_dir=None,
|
||||
)
|
||||
_run(CurrentCommand().execute(ctx, []))
|
||||
await CurrentCommand().execute(ctx, [])
|
||||
calls = [c.args[0] for c in ui.append_system.call_args_list]
|
||||
assert any("Thread: abc123" in s for s in calls)
|
||||
assert not any("Workspace:" in s for s in calls)
|
||||
|
||||
Reference in New Issue
Block a user