From f77e3435cf2cfd3e23d7216e32962921a2d783f5 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 5 Mar 2018 23:10:56 +0100 Subject: [PATCH] tornado 5 fixes in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - start asyncio loop explicitly in notebook thread (tornado 4 starts per-thread loops automatically, asyncio doesn’t) - remove unsupported ‘io_loop=‘ arg in websocket test application runs fine with tornado 5, just a few test bits needed updating --- notebook/services/kernels/tests/test_kernels_api.py | 3 ++- notebook/tests/launchnotebook.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/notebook/services/kernels/tests/test_kernels_api.py b/notebook/services/kernels/tests/test_kernels_api.py index 5358a2094..27d19709e 100644 --- a/notebook/services/kernels/tests/test_kernels_api.py +++ b/notebook/services/kernels/tests/test_kernels_api.py @@ -53,11 +53,12 @@ class KernelAPI(object): def websocket(self, id): loop = IOLoop() + loop.make_current() req = HTTPRequest( url_path_join(self.base_url.replace('http', 'ws', 1), 'api/kernels', id, 'channels'), headers=self.headers, ) - f = websocket_connect(req, io_loop=loop) + f = websocket_connect(req) return loop.run_sync(lambda : f) diff --git a/notebook/tests/launchnotebook.py b/notebook/tests/launchnotebook.py index 492e6c897..43c98814a 100644 --- a/notebook/tests/launchnotebook.py +++ b/notebook/tests/launchnotebook.py @@ -135,6 +135,9 @@ 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,