[Python-checkins] bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)

Miss Islington (bot) webhook-mailer at python.org
Tue Jan 7 08:23:09 EST 2020


https://github.com/python/cpython/commit/10ac0cded26d91c3468e5e5a87cecad7fc0bcebd
commit: 10ac0cded26d91c3468e5e5a87cecad7fc0bcebd
branch: master
author: Andrew Svetlov <andrew.svetlov at gmail.com>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2020-01-07T05:23:01-08:00
summary:

bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)



https://bugs.python.org/issue39191

files:
M Lib/asyncio/base_events.py
M Lib/test/test_asyncio/test_events.py

diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index e53ca73803463..d78724b015370 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -573,7 +573,7 @@ def _do_shutdown(self, future):
         except Exception as ex:
             self.call_soon_threadsafe(future.set_exception, ex)
 
-    def _check_runnung(self):
+    def _check_running(self):
         if self.is_running():
             raise RuntimeError('This event loop is already running')
         if events._get_running_loop() is not None:
@@ -583,7 +583,7 @@ def _check_runnung(self):
     def run_forever(self):
         """Run until stop() is called."""
         self._check_closed()
-        self._check_runnung()
+        self._check_running()
         self._set_coroutine_origin_tracking(self._debug)
         self._thread_id = threading.get_ident()
 
@@ -615,7 +615,7 @@ def run_until_complete(self, future):
         Return the Future's result, or raise its exception.
         """
         self._check_closed()
-        self._check_runnung()
+        self._check_running()
 
         new_task = not futures.isfuture(future)
         future = tasks.ensure_future(future, loop=self)
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 4cbd1ed4712d5..4bdf82ef175a0 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -259,8 +259,12 @@ def test_run_until_complete_nesting(self):
             self.assertTrue(self.loop.is_running())
             self.loop.run_until_complete(coro1())
 
-        self.assertRaises(
-            RuntimeError, self.loop.run_until_complete, coro2())
+        with self.assertWarnsRegex(
+            RuntimeWarning,
+            r"coroutine \S+ was never awaited"
+        ):
+            self.assertRaises(
+                RuntimeError, self.loop.run_until_complete, coro2())
 
     # Note: because of the default Windows timing granularity of
     # 15.6 msec, we use fairly long sleep times here (~100 msec).



More information about the Python-checkins mailing list