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:
Kumar Aditya 2025-02-18 17:38:25 +05:30 committed by GitHub
parent b93b7e566e
commit 2e3e65380b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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