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

Andrew Svetlov webhook-mailer at python.org
Tue Jan 7 09:55:23 EST 2020


https://github.com/python/cpython/commit/4112a3da2e01ecc19e9f54b8ac7b383b6f5e85c8
commit: 4112a3da2e01ecc19e9f54b8ac7b383b6f5e85c8
branch: 3.8
author: Andrew Svetlov <andrew.svetlov at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-01-07T16:55:19+02:00
summary:

[3.8] bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863) (#17894)

https://bugs.python.org/issue39191.
(cherry picked from commit 10ac0cded26d91c3468e5e5a87cecad7fc0bcebd)

Co-authored-by: Andrew Svetlov <andrew.svetlov at gmail.com>

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 aedf0c5e6d3d2..799013d5ccccb 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -547,7 +547,7 @@ def _asyncgen_firstiter_hook(self, agen):
                     'asyncgen': agen
                 })
 
-    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:
@@ -557,7 +557,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()
 
@@ -589,7 +589,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 b0ade1ed3ba1b..aec56da8e2250 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -258,8 +258,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