mirror of
https://github.com/python/cpython.git
synced 2025-09-08 01:41:19 +00:00
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.
This commit is contained in:
parent
b93b7e566e
commit
2e3e65380b
1 changed files with 1 additions and 3 deletions
|
@ -2272,10 +2272,8 @@ class BaseTaskTests:
|
|||
|
||||
self.assertEqual(self.all_tasks(loop=self.loop), {task})
|
||||
|
||||
asyncio._set_event_loop(None)
|
||||
|
||||
# execute the task so it waits for future
|
||||
self.loop._run_once()
|
||||
self.loop.run_until_complete(asyncio.sleep(0))
|
||||
self.assertEqual(len(self.loop._ready), 0)
|
||||
|
||||
coro = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue