From c6bd5f0075dfad8d7ce51c5e4e3f075d56992f86 Mon Sep 17 00:00:00 2001 From: arcdrake22 Date: Mon, 3 Aug 2026 09:13:36 +0200 Subject: [PATCH] test(gateway): align runtime-tasks gather tests with bounded retrieval The helper never waits on the runtime-tasks gather after cancelling it (its children are bounded individually), so the finished-gather test must hand the helper an already-complete gather to exercise the bounded retrieval path, and the cancelled-gather test must settle the gather itself instead of expecting the helper to await a still-pending future. Use a pre-completed child for the finished case and suppress(await) for the cancelled case; both now assert done() and a single close. --- tests/cli/test_gateway_runtime.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/cli/test_gateway_runtime.py b/tests/cli/test_gateway_runtime.py index 14c20f973..daf022350 100644 --- a/tests/cli/test_gateway_runtime.py +++ b/tests/cli/test_gateway_runtime.py @@ -9,6 +9,7 @@ block the stop. import asyncio import time +from contextlib import suppress from nanobot.cli.gateway_runtime import _close_gateway_runtime @@ -160,7 +161,10 @@ async def test_duplicate_cleanup_is_idempotent() -> None: async def test_finished_runtime_tasks_gather_is_retrieved() -> None: agent = _FakeAgent() channels = _FakeChannels() - runtime_tasks = asyncio.gather(asyncio.sleep(0)) + finished = asyncio.get_running_loop().create_future() + finished.set_result(None) + runtime_tasks = asyncio.gather(finished) + await asyncio.sleep(0) # let the gather observe the finished child await _close_gateway_runtime(agent, channels, [], runtime_tasks) @@ -175,6 +179,8 @@ async def test_cancelled_runtime_tasks_gather_does_not_raise() -> None: runtime_tasks.cancel() await _close_gateway_runtime(agent, channels, [], runtime_tasks) + with suppress(asyncio.CancelledError): + await runtime_tasks # settle the cancelled gather without raising assert runtime_tasks.done() # the cancelled gather was awaited without raising assert agent.close_calls == 1