fix: fix test race condition
ref: N25B-301
This commit is contained in:
@@ -33,14 +33,16 @@ async def test_agent_lifecycle():
|
||||
|
||||
# Test background task
|
||||
async def dummy_task():
|
||||
await asyncio.sleep(0.01)
|
||||
pass
|
||||
|
||||
await agent.add_behavior(dummy_task())
|
||||
assert len(agent._tasks) > 0
|
||||
task = agent.add_behavior(dummy_task())
|
||||
assert task in agent._tasks
|
||||
|
||||
await task
|
||||
|
||||
# Wait for task to finish
|
||||
await asyncio.sleep(0.02)
|
||||
assert len(agent._tasks) == 2 # message handling tasks are running
|
||||
assert task not in agent._tasks
|
||||
assert len(agent._tasks) == 2 # message handling tasks are still running
|
||||
|
||||
await agent.stop()
|
||||
assert agent._running is False
|
||||
|
||||
Reference in New Issue
Block a user