diff options
author | Kyle Stanley <aeros167@gmail.com> | 2019-12-30 06:50:19 -0500 |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2019-12-30 13:50:19 +0200 |
commit | 89aa7f0ede1a11c020e83f24394593c577a61509 (patch) | |
tree | e570c3365f871fa9e7c82909e48d81c85f3ad718 /Lib/test/test_asyncio/test_tasks.py | |
parent | 88dce26da6bc4838092128d9a6f1c98bf48b7c90 (diff) | |
download | cpython-89aa7f0ede1a11c020e83f24394593c577a61509.tar.gz cpython-89aa7f0ede1a11c020e83f24394593c577a61509.zip |
bpo-34790: Implement deprecation of passing coroutines to asyncio.wait() (GH-16977)
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index dde84b84b10..68f3b8cce9f 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -979,12 +979,12 @@ class BaseTaskTests: def coro(s): return s c = coro('test') - - task =self.new_task( + task = self.new_task( self.loop, asyncio.wait([c, c, coro('spam')])) - done, pending = self.loop.run_until_complete(task) + with self.assertWarns(DeprecationWarning): + done, pending = self.loop.run_until_complete(task) self.assertFalse(pending) self.assertEqual(set(f.result() for f in done), {'test', 'spam'}) @@ -1346,7 +1346,9 @@ class BaseTaskTests: futs = list(asyncio.as_completed(fs, loop=loop)) self.assertEqual(len(futs), 2) waiter = asyncio.wait(futs) - done, pending = loop.run_until_complete(waiter) + # Deprecation from passing coros in futs to asyncio.wait() + with self.assertWarns(DeprecationWarning): + done, pending = loop.run_until_complete(waiter) self.assertEqual(set(f.result() for f in done), {'a', 'b'}) def test_as_completed_duplicate_coroutines(self): @@ -1751,7 +1753,8 @@ class BaseTaskTests: async def outer(): nonlocal proof - d, p = await asyncio.wait([inner()]) + with self.assertWarns(DeprecationWarning): + d, p = await asyncio.wait([inner()]) proof += 100 f = asyncio.ensure_future(outer(), loop=self.loop) @@ -3307,6 +3310,17 @@ class WaitTests(test_utils.TestCase): self.loop.run_until_complete( asyncio.wait_for(coroutine_function(), 0.01, loop=self.loop)) + def test_coro_is_deprecated_in_wait(self): + # Remove test when passing coros to asyncio.wait() is removed in 3.11 + with self.assertWarns(DeprecationWarning): + self.loop.run_until_complete( + asyncio.wait([coroutine_function()])) + + task = self.loop.create_task(coroutine_function()) + with self.assertWarns(DeprecationWarning): + self.loop.run_until_complete( + asyncio.wait([task, coroutine_function()])) + class CompatibilityTests(test_utils.TestCase): # Tests for checking a bridge between old-styled coroutines |