apply asyncio patch before launching new loop for tests

This commit is contained in:
Min RK 2019-11-14 12:00:23 +01:00
parent 29ec93627c
commit 7e2ae22aee

View File

@ -140,9 +140,6 @@ class NotebookTestBase(TestCase):
started = Event() started = Event()
def start_thread(): def start_thread():
if 'asyncio' in sys.modules:
import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())
app = cls.notebook = NotebookApp( app = cls.notebook = NotebookApp(
port=cls.port, port=cls.port,
port_retries=0, port_retries=0,
@ -156,6 +153,10 @@ class NotebookTestBase(TestCase):
allow_root=True, allow_root=True,
token=cls.token, token=cls.token,
) )
if 'asyncio' in sys.modules:
app._init_asyncio_patch()
import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())
# don't register signal handler during tests # don't register signal handler during tests
app.init_signal = lambda : None app.init_signal = lambda : None
# clear log handlers and propagate to root for nose to capture it # clear log handlers and propagate to root for nose to capture it