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``. diff --git a/tests/test_websocket.py b/tests/test_websocket.py index eb3f22e..5f0ee0c 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)