diff options
author | João Júnior <joaojunior.ma@gmail.com> | 2018-09-24 09:51:22 (GMT) |
---|---|---|
committer | Carol Willing <carolcode@willingconsulting.com> | 2018-09-24 09:51:22 (GMT) |
commit | 558c49bcf3a8543d64a68de836b5d855efd56696 (patch) | |
tree | 933e87600d6e381d6c836aa81f1f168d52966919 /Lib/test/test_asyncio | |
parent | a0fd7f1b55a1d76842fa2c6b5777a39cdcf2bb5e (diff) | |
download | cpython-558c49bcf3a8543d64a68de836b5d855efd56696.zip cpython-558c49bcf3a8543d64a68de836b5d855efd56696.tar.gz cpython-558c49bcf3a8543d64a68de836b5d855efd56696.tar.bz2 |
bpo-34728: Remove deprecate *loop* argument in asyncio.sleep (GH-9415)
* Insert the warn in the asyncio.sleep when the loop argument is used
* Insert the warn in the asyncio.wait and asyncio.wait_for when the loop argument is used
* Better format of the code
* Add news file
* change calls for get_event_loop() to calls for get_running_loop()
* Change message to be more clear in News
* Improve the comments in test_tasks
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 40d1953..ea54706 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -3220,6 +3220,35 @@ class SleepTests(test_utils.TestCase): self.loop.run_until_complete(coro()) self.assertEqual(result, 11) + def test_loop_argument_is_deprecated(self): + # Remove test when loop argument is removed in Python 4.0 + with self.assertWarns(DeprecationWarning): + self.loop.run_until_complete(asyncio.sleep(0.01, loop=self.loop)) + + +class WaitTests(test_utils.TestCase): + def setUp(self): + super().setUp() + self.loop = asyncio.new_event_loop() + asyncio.set_event_loop(None) + + def tearDown(self): + self.loop.close() + self.loop = None + super().tearDown() + + def test_loop_argument_is_deprecated_in_wait(self): + # Remove test when loop argument is removed in Python 4.0 + with self.assertWarns(DeprecationWarning): + self.loop.run_until_complete( + asyncio.wait([coroutine_function()], loop=self.loop)) + + def test_loop_argument_is_deprecated_in_wait_for(self): + # Remove test when loop argument is removed in Python 4.0 + with self.assertWarns(DeprecationWarning): + self.loop.run_until_complete( + asyncio.wait_for(coroutine_function(), 0.01, loop=self.loop)) + class CompatibilityTests(test_utils.TestCase): # Tests for checking a bridge between old-styled coroutines |