From e69cb12652d2737e0f78e6bffda4b8f773a411ba Mon Sep 17 00:00:00 2001 From: Andrew Mirsky Date: Mon, 9 Jun 2025 12:21:22 -0400 Subject: [PATCH] fixing test case for python 3.12 --- tests/test_broker.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_broker.py b/tests/test_broker.py index ae8355b..8fb720e 100644 --- a/tests/test_broker.py +++ b/tests/test_broker.py @@ -742,13 +742,14 @@ async def test_broker_broadcast_cancellation(broker): assert message -def test_broker_socket_open_close(broker): +@pytest.mark.asyncio +async def test_broker_socket_open_close(broker): # check that https://github.com/Yakifo/amqtt/issues/86 is fixed + # mqtt 3.1 requires a connect packet, otherwise the socket connection is rejected static_connect_packet = b'\x10\x1b\x00\x04MQTT\x04\x02\x00<\x00\x0ftest-client-123' - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server = ('localhost', 1883) - sock.connect(server) - sock.send(static_connect_packet) - sock.close() + s = socket.create_connection(("127.0.0.1", 1883)) + s.send(static_connect_packet) + await asyncio.sleep(0.1) + s.close()