summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2020-01-07 15:23:01 +0200
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-01-07 05:23:01 -0800
commit10ac0cded26d91c3468e5e5a87cecad7fc0bcebd (patch)
tree8adf1c1be164e312c31d927105c60d04ca69a094
parentca94677a6216e2d41b04574986ce49d31a0b329c (diff)
downloadcpython-git-10ac0cded26d91c3468e5e5a87cecad7fc0bcebd.tar.gz
bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)
https://bugs.python.org/issue39191
-rw-r--r--Lib/asyncio/base_events.py6
-rw-r--r--Lib/test/test_asyncio/test_events.py8
2 files changed, 9 insertions, 5 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index e53ca73803..d78724b015 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -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)
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 4cbd1ed471..4bdf82ef17 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -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).