Skip to content

Commit 2e3e653

Browse files
improve test_tasks to use correct idiom for starting task in asyncio (#130257)
The test should use the correct idiom for starting the task, `loop._run_once` is private API which should not be used directly, instead use `asyncio.sleep(0)` for 1 event loop cycle.
1 parent b93b7e5 commit 2e3e653

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Lib/test/test_asyncio/test_tasks.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2272,10 +2272,8 @@ async def kill_me(loop):
22722272

22732273
self.assertEqual(self.all_tasks(loop=self.loop), {task})
22742274

2275-
asyncio._set_event_loop(None)
2276-
22772275
# execute the task so it waits for future
2278-
self.loop._run_once()
2276+
self.loop.run_until_complete(asyncio.sleep(0))
22792277
self.assertEqual(len(self.loop._ready), 0)
22802278

22812279
coro = None

0 commit comments

Comments
 (0)