diff options
author | Emmanuel Arias <emmanuelarias30@gmail.com> | 2019-09-10 07:55:07 -0300 |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-09-10 03:55:07 -0700 |
commit | 537877d85d1c27d2c2f5189e39da64a7a0c413d3 (patch) | |
tree | 44b52523924c0c5496ceba24ffbe0b6ba95e569f /Lib/test/test_asyncio/test_tasks.py | |
parent | 9669931e5e76cf4b6ae6d3d66e699b5fd6ffe931 (diff) | |
download | cpython-537877d85d1c27d2c2f5189e39da64a7a0c413d3.tar.gz cpython-537877d85d1c27d2c2f5189e39da64a7a0c413d3.zip |
bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [locks] (GH-13920)
This PR deprecate explicit loop parameters in all public asyncio APIs
This issues is split to be easier to review.
Third step: locks.py
https://bugs.python.org/issue36373
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index d5f44b8091d..323c0907a23 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -1231,15 +1231,16 @@ class BaseTaskTests: for f in asyncio.as_completed([b, c, a], loop=loop): values.append(await f) return values - - res = loop.run_until_complete(self.new_task(loop, foo())) + with self.assertWarns(DeprecationWarning): + res = loop.run_until_complete(self.new_task(loop, foo())) self.assertAlmostEqual(0.15, loop.time()) self.assertTrue('a' in res[:2]) self.assertTrue('b' in res[:2]) self.assertEqual(res[2], 'c') # Doing it again should take no time and exercise a different path. - res = loop.run_until_complete(self.new_task(loop, foo())) + with self.assertWarns(DeprecationWarning): + res = loop.run_until_complete(self.new_task(loop, foo())) self.assertAlmostEqual(0.15, loop.time()) def test_as_completed_with_timeout(self): @@ -1267,7 +1268,8 @@ class BaseTaskTests: values.append((2, exc)) return values - res = loop.run_until_complete(self.new_task(loop, foo())) + with self.assertWarns(DeprecationWarning): + res = loop.run_until_complete(self.new_task(loop, foo())) self.assertEqual(len(res), 2, res) self.assertEqual(res[0], (1, 'a')) self.assertEqual(res[1][0], 2) @@ -1294,7 +1296,8 @@ class BaseTaskTests: v = await f self.assertEqual(v, 'a') - loop.run_until_complete(self.new_task(loop, foo())) + with self.assertWarns(DeprecationWarning): + loop.run_until_complete(self.new_task(loop, foo())) def test_as_completed_reverse_wait(self): @@ -1308,7 +1311,9 @@ class BaseTaskTests: a = asyncio.sleep(0.05, 'a') b = asyncio.sleep(0.10, 'b') fs = {a, b} - futs = list(asyncio.as_completed(fs, loop=loop)) + + with self.assertWarns(DeprecationWarning): + futs = list(asyncio.as_completed(fs, loop=loop)) self.assertEqual(len(futs), 2) x = loop.run_until_complete(futs[1]) @@ -1333,7 +1338,8 @@ class BaseTaskTests: a = asyncio.sleep(0.05, 'a') b = asyncio.sleep(0.05, 'b') fs = {a, b} - futs = list(asyncio.as_completed(fs, loop=loop)) + with self.assertWarns(DeprecationWarning): + futs = list(asyncio.as_completed(fs, loop=loop)) self.assertEqual(len(futs), 2) waiter = asyncio.wait(futs) done, pending = loop.run_until_complete(waiter) @@ -1356,8 +1362,9 @@ class BaseTaskTests: result.append((yield from f)) return result - fut = self.new_task(self.loop, runner()) - self.loop.run_until_complete(fut) + with self.assertWarns(DeprecationWarning): + fut = self.new_task(self.loop, runner()) + self.loop.run_until_complete(fut) result = fut.result() self.assertEqual(set(result), {'ham', 'spam'}) self.assertEqual(len(result), 2) |