From a0573da9d488008cdca5c5b1fd0d7c3519b3663e Mon Sep 17 00:00:00 2001 From: Jonathan Ehwald Date: Sun, 15 Dec 2024 00:06:35 +0100 Subject: [PATCH] Fix aiohttp test server teardown (#3726) --- tests/http/clients/aiohttp.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/http/clients/aiohttp.py b/tests/http/clients/aiohttp.py index 12cb035937..c6ce2b8fe7 100644 --- a/tests/http/clients/aiohttp.py +++ b/tests/http/clients/aiohttp.py @@ -172,11 +172,9 @@ async def ws_connect( *, protocols: List[str], ) -> AsyncGenerator[WebSocketClient, None]: - server = TestServer(self.app) - await server.start_server() - client = TestClient(server) - async with client.ws_connect(url, protocols=protocols) as ws: - yield AioWebSocketClient(ws) + async with TestClient(TestServer(self.app)) as client: + async with client.ws_connect(url, protocols=protocols) as ws: + yield AioWebSocketClient(ws) class AioWebSocketClient(WebSocketClient):