From 2439f07098f3f3ad7b692bc3b715015c84305231 Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Mon, 2 Dec 2024 10:29:46 +0100 Subject: [PATCH] fix: Do not garbage collect the tcp test server --- tests/pytest/test_transports.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/pytest/test_transports.py b/tests/pytest/test_transports.py index 36f48702c..7c2f2eb5b 100644 --- a/tests/pytest/test_transports.py +++ b/tests/pytest/test_transports.py @@ -126,7 +126,10 @@ async def test_tcp_linesep_request(tcp_server: TCPServer) -> None: @pytest.mark.asyncio async def test_tcp_timeout(tcp_server: TCPServer) -> None: client = await TCPLinesTransport.connect(TargetURI("tcp-lines://127.0.0.1:1234")) - await tcp_server.accept() + server = await tcp_server.accept() + + async with asyncio.TaskGroup() as tg: + tg.create_task(server.read()) - with pytest.raises(asyncio.TimeoutError): - await client.request(b"hello", timeout=0.5) + with pytest.raises(asyncio.TimeoutError): + await client.request(b"hello", timeout=0.5)