From 69ad26f17724f347b2a34784677171bb91428075 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 7 Mar 2022 23:05:06 +0100 Subject: [PATCH 1/3] new black --- asgineer/_request.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asgineer/_request.py b/asgineer/_request.py index ac824f2..db8c1ea 100644 --- a/asgineer/_request.py +++ b/asgineer/_request.py @@ -267,7 +267,7 @@ async def iter_body(self): if self._client_state != CONNECTED: # i.e. DONE or DISCONNECTED break - async def get_body(self, limit=10 * 2 ** 20): + async def get_body(self, limit=10 * 2**20): """Async function to get the bytes of the body. If the end of the stream is not reached before the byte limit is reached (default 10MiB), raises an ``IOError``. @@ -284,7 +284,7 @@ async def get_body(self, limit=10 * 2 ** 20): self._body = b"".join(chunks) return self._body - async def get_json(self, limit=10 * 2 ** 20): + async def get_json(self, limit=10 * 2**20): """Async function to get the body as a dict. If the end of the stream is not reached before the byte limit is reached (default 10MiB), raises an ``IOError``. From b61e3ff97430dcccaadd1a83a138be2ba7bbe569 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 7 Mar 2022 23:29:15 +0100 Subject: [PATCH 2/3] fix test --- tests/test_websocket.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_websocket.py b/tests/test_websocket.py index eb3f22e..449e3ae 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -5,7 +5,8 @@ import sys import asgineer -from common import make_server +from common import make_server, get_backend +from pytest import skip def test_websocket1(): @@ -231,6 +232,9 @@ async def client(ws): def test_websocket_receive_after_close(): + if get_backend() != "daphne": + skip("This test outcome is ill defined, skipping for daphne") + async def handle_ws1(request): await request.accept() await request.close() @@ -242,11 +246,12 @@ async def client(ws): with make_server(handle_ws1) as p: p.ws_communicate("/", client) + out = p.out.strip() - # Acually, uvicorn gives empty string, daphne gives hello, not sure + # Acually, uvicorn gives empty string, daphne gives error, not sure # what the official behavior is, I guess we'll allow both. - print("receive_after_close:", p.out.strip()) - assert p.out.strip() in ("", "hellow") + print("receive_after_close:", out) + assert out in ("", "hellow") def test_websocket_receive_after_disconnect1(): @@ -291,6 +296,9 @@ async def client(ws): def test_websocket_send_invalid_data(): + if get_backend() != "daphne": + skip("Skipping on daphne because it errors on the close mechanic") + async def handle_ws(request): await request.accept() await request.send(4) From ef5065db310f61b02619453eb5505dc81100570d Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 7 Mar 2022 23:44:50 +0100 Subject: [PATCH 3/3] fix --- tests/test_websocket.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_websocket.py b/tests/test_websocket.py index 449e3ae..5f0ee0c 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -232,7 +232,7 @@ async def client(ws): def test_websocket_receive_after_close(): - if get_backend() != "daphne": + if get_backend() == "daphne": skip("This test outcome is ill defined, skipping for daphne") async def handle_ws1(request): @@ -296,7 +296,7 @@ async def client(ws): def test_websocket_send_invalid_data(): - if get_backend() != "daphne": + if get_backend() == "daphne": skip("Skipping on daphne because it errors on the close mechanic") async def handle_ws(request):