aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorKumar Aditya <kumaraditya@python.org>2025-02-18 17:38:25 +0530
committerGitHub <noreply@github.com>2025-02-18 12:08:25 +0000
commit2e3e65380b91124267212114c7f62b85edf6e810 (patch)
treed790b2511b5ac42e28cb6d9346922d5e8eefaafb /Lib/test/test_asyncio/test_tasks.py
parentb93b7e566e5a4efe7f077af2083140e50bd2b08f (diff)
downloadcpython-2e3e65380b91124267212114c7f62b85edf6e810.tar.gz
cpython-2e3e65380b91124267212114c7f62b85edf6e810.zip
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.
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index de2e658bca6..591b48b88a2 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