diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2023-03-17 01:28:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-17 01:28:43 (GMT) |
commit | 4f5774f648eafd1a7076ecf9af9629fb81baa363 (patch) | |
tree | b5443a42ecb33ef0a86591c00edadaf6615fb556 /Lib/test/test_asyncio | |
parent | f33b33eb31c11a32b2955eb1f002f02267bd7d61 (diff) | |
download | cpython-4f5774f648eafd1a7076ecf9af9629fb81baa363.zip cpython-4f5774f648eafd1a7076ecf9af9629fb81baa363.tar.gz cpython-4f5774f648eafd1a7076ecf9af9629fb81baa363.tar.bz2 |
GH-78530: add support for generators in `asyncio.wait` (#102761)
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 5b935b5..731fa0c 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -1373,6 +1373,22 @@ class BaseTaskTests: self.assertEqual(res, 42) self.assertAlmostEqual(0.15, loop.time()) + + def test_wait_generator(self): + async def func(a): + return a + + loop = self.new_test_loop() + + async def main(): + tasks = (self.new_task(loop, func(i)) for i in range(10)) + done, pending = await asyncio.wait(tasks, return_when=asyncio.ALL_COMPLETED) + self.assertEqual(len(done), 10) + self.assertEqual(len(pending), 0) + + loop.run_until_complete(main()) + + def test_as_completed(self): def gen(): |