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