diff --git a/notebook/tests/launchnotebook.py b/notebook/tests/launchnotebook.py index 916d6072d..e84e15642 100644 --- a/notebook/tests/launchnotebook.py +++ b/notebook/tests/launchnotebook.py @@ -140,9 +140,6 @@ class NotebookTestBase(TestCase): started = Event() def start_thread(): - if 'asyncio' in sys.modules: - import asyncio - asyncio.set_event_loop(asyncio.new_event_loop()) app = cls.notebook = NotebookApp( port=cls.port, port_retries=0, @@ -156,6 +153,10 @@ class NotebookTestBase(TestCase): allow_root=True, 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 app.init_signal = lambda : None # clear log handlers and propagate to root for nose to capture it