Skip to content

Commit 2d851ad

Browse files
test: Ensure asyncio tasks are created correctly in tests (#230)
Fixes #229 🦕
1 parent 295e6e3 commit 2d851ad

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/server/tasks/test_result_aggregator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import unittest
23

34
from collections.abc import AsyncIterator
@@ -252,6 +253,7 @@ async def mock_consume_generator():
252253

253254
# Mock _continue_consuming to check if it's called by create_task
254255
self.aggregator._continue_consuming = AsyncMock()
256+
mock_create_task.side_effect = lambda coro: asyncio.ensure_future(coro)
255257

256258
(
257259
result,
@@ -303,6 +305,7 @@ async def mock_consume_generator():
303305
current_task_state_after_update
304306
)
305307
self.aggregator._continue_consuming = AsyncMock()
308+
mock_create_task.side_effect = lambda coro: asyncio.ensure_future(coro)
306309

307310
(
308311
result,
@@ -417,6 +420,7 @@ async def initial_consume_generator():
417420
self.mock_task_manager.get_task.return_value = (
418421
auth_event # Task state at interrupt
419422
)
423+
mock_create_task.side_effect = lambda coro: asyncio.ensure_future(coro)
420424

421425
# Call the main method that triggers _continue_consuming via create_task
422426
_, _ = await self.aggregator.consume_and_break_on_interrupt(

0 commit comments

Comments
 (0)