From 2e3e65380b91124267212114c7f62b85edf6e810 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 18 Feb 2025 17:38:25 +0530 Subject: 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. --- Lib/test/test_asyncio/test_tasks.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index de2e658..591b48b 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -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 -- cgit v0.12