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

https://bugs.python.org/issue39191
This commit is contained in:
Andrew Svetlov 2020-01-07 15:23:01 +02:00 committed by Miss Islington (bot)
parent ca94677a62
commit 10ac0cded2
2 changed files with 9 additions and 5 deletions

View 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)

View File

@ -259,6 +259,10 @@ class EventLoopTestsMixin:
self.assertTrue(self.loop.is_running())
self.loop.run_until_complete(coro1())
with self.assertWarnsRegex(
RuntimeWarning,
r"coroutine \S+ was never awaited"
):
self.assertRaises(
RuntimeError, self.loop.run_until_complete, coro2())