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:
@@ -4,7 +4,6 @@ from unittest.mock import MagicMock
|
||||
|
||||
from rich.table import Table
|
||||
|
||||
from tests.conftest import run_async as _run
|
||||
from tests.fakes import FakeGraphGateway, FakeThreadStore
|
||||
|
||||
|
||||
@@ -24,15 +23,15 @@ def _ctx(**overrides):
|
||||
|
||||
|
||||
class TestThreadsCommand:
|
||||
def test_empty_list_prints_message(self):
|
||||
async def test_empty_list_prints_message(self):
|
||||
from EvoScientist.commands.implementation.session import ThreadsCommand
|
||||
|
||||
ctx, ui = _ctx()
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
await ThreadsCommand().execute(ctx, [])
|
||||
ui.append_system.assert_called_once()
|
||||
assert "No saved sessions" in ui.append_system.call_args.args[0]
|
||||
|
||||
def test_renders_table_with_current_marker(self):
|
||||
async def test_renders_table_with_current_marker(self):
|
||||
from EvoScientist.commands.implementation.session import ThreadsCommand
|
||||
|
||||
ctx, ui = _ctx(thread_id="current")
|
||||
@@ -54,7 +53,7 @@ class TestThreadsCommand:
|
||||
]
|
||||
store = FakeThreadStore(threads=threads)
|
||||
ctx.graph_gateway = FakeGraphGateway(thread_store=store)
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
await ThreadsCommand().execute(ctx, [])
|
||||
ui.mount_renderable.assert_called_once()
|
||||
table = ui.mount_renderable.call_args.args[0]
|
||||
assert isinstance(table, Table)
|
||||
@@ -64,7 +63,7 @@ class TestThreadsCommand:
|
||||
assert "/delete" in footer
|
||||
assert "/new" in footer
|
||||
|
||||
def test_footer_hint_suppressed_in_channel_mode(self):
|
||||
async def test_footer_hint_suppressed_in_channel_mode(self):
|
||||
"""Channels don't get the footer — keeps outbound text short."""
|
||||
from EvoScientist.commands.implementation.session import ThreadsCommand
|
||||
|
||||
@@ -80,10 +79,10 @@ class TestThreadsCommand:
|
||||
]
|
||||
store = FakeThreadStore(threads=threads)
|
||||
ctx.graph_gateway = FakeGraphGateway(thread_store=store)
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
await ThreadsCommand().execute(ctx, [])
|
||||
ui.append_system.assert_not_called()
|
||||
|
||||
def test_channel_mode_drops_model_column(self):
|
||||
async def test_channel_mode_drops_model_column(self):
|
||||
"""Non-interactive (channel) UIs get a narrower table."""
|
||||
from EvoScientist.commands.implementation.session import ThreadsCommand
|
||||
|
||||
@@ -99,7 +98,7 @@ class TestThreadsCommand:
|
||||
]
|
||||
store = FakeThreadStore(threads=threads)
|
||||
ctx.graph_gateway = FakeGraphGateway(thread_store=store)
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
await ThreadsCommand().execute(ctx, [])
|
||||
# Channel mode: no Model column. 4 columns: ID, Preview, Msgs, Last Used.
|
||||
table = ui.mount_renderable.call_args.args[0]
|
||||
column_headers = [col.header for col in table.columns]
|
||||
|
||||
Reference in New Issue
Block a user