self.asyncio_loop.run_until_complete(native_coroutine_with_adapter2()),
42,
)
+ # I'm not entirely sure why this manual cleanup is necessary but without
+ # it we have at-a-distance failures in ioloop_test.TestIOLoopCurrent.
+ asyncio.set_event_loop(None)
class LeakTest(unittest.TestCase):
from tornado import gen, ioloop
from tornado.httpserver import HTTPServer
from tornado.locks import Event
+from tornado.test.util import ignore_deprecation
from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, bind_unused_port, gen_test
from tornado.web import Application
import asyncio
def setUp(self):
# This simulates the effect of an asyncio test harness like
# pytest-asyncio.
- self.orig_loop = asyncio.get_event_loop()
+ with ignore_deprecation():
+ try:
+ self.orig_loop = asyncio.get_event_loop()
+ except RuntimeError:
+ self.orig_loop = None
self.new_loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.new_loop)
super().setUp()