From f9b29fd7e746301624d3d1a3501b1c47287eb297 Mon Sep 17 00:00:00 2001 From: 7 Date: Tue, 3 Jul 2018 22:07:08 -0700 Subject: [PATCH] py37 (#1256) * add py37 to travisci * use dist:xenial for py37 * sudo: true in .travici * bump websockets version for py37 support and fix unit tests --- .travis.yml | 8 ++++++++ requirements.txt | 2 +- sanic/server.py | 2 +- sanic/worker.py | 2 +- setup.py | 2 +- tests/test_worker.py | 2 +- tox.ini | 6 +++--- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1fa1df57..c18e895b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,14 @@ matrix: python: 3.6 - env: TOX_ENV=py36-no-ext python: 3.6 + - env: TOX_ENV=py37 + python: 3.7 + dist: xenial + sudo: true + - env: TOX_ENV=py37-no-ext + python: 3.7 + dist: xenial + sudo: true - env: TOX_ENV=flake8 python: 3.6 - env: TOX_ENV=check diff --git a/requirements.txt b/requirements.txt index b15a3572..05968bd8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ aiofiles httptools ujson; sys_platform != "win32" and implementation_name == "cpython" uvloop; sys_platform != "win32" and implementation_name == "cpython" -websockets>=4.0,<5.0 +websockets>=5.0,<6.0 diff --git a/sanic/server.py b/sanic/server.py index 15ae4708..fc8291b5 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -665,7 +665,7 @@ def serve(host, port, request_handler, error_handler, before_start=None, for conn in connections: if hasattr(conn, "websocket") and conn.websocket: coros.append( - conn.websocket.close_connection(after_handshake=True) + conn.websocket.close_connection() ) else: conn.close() diff --git a/sanic/worker.py b/sanic/worker.py index 3d8a4617..d367a7c3 100644 --- a/sanic/worker.py +++ b/sanic/worker.py @@ -116,7 +116,7 @@ class GunicornWorker(base.Worker): for conn in self.connections: if hasattr(conn, "websocket") and conn.websocket: coros.append( - conn.websocket.close_connection(after_handshake=False) + conn.websocket.close_connection() ) else: conn.close() diff --git a/setup.py b/setup.py index 5954b926..73cb559f 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ requirements = [ uvloop, ujson, 'aiofiles>=0.3.0', - 'websockets>=4.0,<5.0', + 'websockets>=5.0,<6.0', ] if strtobool(os.environ.get("SANIC_NO_UJSON", "no")): print("Installing without uJSON") diff --git a/tests/test_worker.py b/tests/test_worker.py index af00982e..0dcd1f38 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -131,5 +131,5 @@ def test_worker_close(worker): loop.run_until_complete(_close) assert worker.signal.stopped == True - conn.websocket.close_connection.assert_called_with(after_handshake=False) + assert conn.websocket.close_connection.called == True assert len(worker.servers) == 0 diff --git a/tox.ini b/tox.ini index a62368e2..cb8e4fc9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ [tox] -envlist = py35, py36, {py35,py36}-no-ext, flake8, check +envlist = py35, py36, py37, {py35,py36,py37}-no-ext, flake8, check [testenv] usedevelop = True setenv = - {py35,py36}-no-ext: SANIC_NO_UJSON=1 - {py35,py36}-no-ext: SANIC_NO_UVLOOP=1 + {py35,py36,py37}-no-ext: SANIC_NO_UJSON=1 + {py35,py36,py37}-no-ext: SANIC_NO_UVLOOP=1 deps = coverage pytest==3.3.2