]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Tue, 7 Jan 2020 13:23:01 +0000 (15:23 +0200)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 7 Jan 2020 13:23:01 +0000 (05:23 -0800)
https://bugs.python.org/issue39191

Lib/asyncio/base_events.py
Lib/test/test_asyncio/test_events.py

index e53ca738034635c66bd86fca11fd1815078084e4..d78724b015370e6b2a2b1408aa23c64f4b0fffc7 100644 (file)
@@ -573,7 +573,7 @@ class BaseEventLoop(events.AbstractEventLoop):
         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 @@ class BaseEventLoop(events.AbstractEventLoop):
     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 @@ class BaseEventLoop(events.AbstractEventLoop):
         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)
index 4cbd1ed4712d51f6ad5c52e394e91113463cc60f..4bdf82ef175a0d8ba0cf88f6d39457aadfa083ff 100644 (file)
@@ -259,8 +259,12 @@ class EventLoopTestsMixin:
             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).