From 8075397a01987bd7a91cc04e40206e03be78d1a2 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Thu, 5 Nov 2026 09:54:52 +0800 Subject: [PATCH] test(agent): guard maintenance transitions separately --- tests/agent/test_runtime_maintenance.py | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/agent/test_runtime_maintenance.py b/tests/agent/test_runtime_maintenance.py index 546c697b1..1071c050d 100644 --- a/tests/agent/test_runtime_maintenance.py +++ b/tests/agent/test_runtime_maintenance.py @@ -103,22 +103,25 @@ async def test_direct_turn_including_final_notification_stays_busy(agent, cancel agent.runtime_event_publisher.run_status_changed = notify task = asyncio.create_task(agent.process_direct("work")) try: + # Guard each transition, not the total duration of startup and storage. async with asyncio.timeout(3): await entered.wait() - with pytest.raises(RuntimeBusyError): - with agent.maintenance(): - pytest.fail("active direct turn was missed") - assert not agent.bus.admission.paused - assert not task.done() - if cancel: - task.cancel() - else: - release.set() + with pytest.raises(RuntimeBusyError): + with agent.maintenance(): + pytest.fail("active direct turn was missed") + assert not agent.bus.admission.paused + assert not task.done() + if cancel: + task.cancel() + else: + release.set() + async with asyncio.timeout(3): await notifying.wait() - with pytest.raises(RuntimeBusyError): - with agent.maintenance(): - pytest.fail("final notification was missed") - notified.set() + with pytest.raises(RuntimeBusyError): + with agent.maintenance(): + pytest.fail("final notification was missed") + notified.set() + async with asyncio.timeout(3): if cancel: with pytest.raises(asyncio.CancelledError): await task