diff --git a/sanic_testing/websocket.py b/sanic_testing/websocket.py index 526565a..9909eb4 100644 --- a/sanic_testing/websocket.py +++ b/sanic_testing/websocket.py @@ -1,7 +1,7 @@ import typing from websockets.exceptions import ConnectionClosedOK -from websockets.legacy.client import connect +from websockets.asyncio.client import connect class WebsocketProxy: diff --git a/tests/test_test_client.py b/tests/test_test_client.py index b2e72f0..ef5e9b0 100644 --- a/tests/test_test_client.py +++ b/tests/test_test_client.py @@ -3,7 +3,7 @@ import pytest from sanic import Sanic, Websocket from sanic.request import Request -from websockets.client import WebSocketClientProtocol +from websockets.asyncio.client import ClientConnection @pytest.mark.parametrize( @@ -33,7 +33,7 @@ async def handler(request, ws): def test_websocket_route_queue(app: Sanic): - async def client_mimic(websocket: WebSocketClientProtocol): + async def client_mimic(websocket: ClientConnection): await websocket.send("foo") await websocket.recv() @@ -54,7 +54,7 @@ def test_websocket_client_mimic_failed(app: Sanic): async def handler(request, ws: Websocket): pass - async def client_mimic(websocket: WebSocketClientProtocol): + async def client_mimic(websocket: ClientConnection): raise Exception("Should fails") with pytest.raises(Exception, match="Should fails"):