From 7a3a79106790351626ba63c11bc48dd7d906bce8 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sat, 20 Jul 2024 09:24:31 +0200 Subject: [PATCH] Correct flaky force_poll tests. --- test/transport/test_comm.py | 5 +++++ test/transport/test_serial.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/test/transport/test_comm.py b/test/transport/test_comm.py index 8b175bc09..35b25c52c 100644 --- a/test/transport/test_comm.py +++ b/test/transport/test_comm.py @@ -174,6 +174,10 @@ async def test_split_serial_packet(self, client, server, use_port): ) async def test_serial_poll(self, client, server, use_port): """Test connection and data exchange.""" + if SerialTransport.force_poll: + client.close() + server.close() + return Log.debug("test_serial_poll {}", use_port) assert await server.listen() SerialTransport.force_poll = True @@ -188,6 +192,7 @@ async def test_serial_poll(self, client, server, use_port): assert not client.recv_buffer client.close() server.close() + SerialTransport.force_poll = False @pytest.mark.parametrize( ("use_comm_type", "use_host"), diff --git a/test/transport/test_serial.py b/test/transport/test_serial.py index f40eb805d..702c0d441 100644 --- a/test/transport/test_serial.py +++ b/test/transport/test_serial.py @@ -81,6 +81,8 @@ async def test_create_serial(self): async def test_force_poll(self): """Test external methods.""" + if SerialTransport.force_poll: + return SerialTransport.force_poll = True transport, protocol = await create_serial_connection( asyncio.get_running_loop(), mock.Mock, "dummy" @@ -94,6 +96,8 @@ async def test_force_poll(self): async def test_write_force_poll(self): """Test write with poll.""" + if SerialTransport.force_poll: + return SerialTransport.force_poll = True transport, protocol = await create_serial_connection( asyncio.get_running_loop(), mock.Mock, "dummy"