From ec31def92c368a2b9f4eb07016a8bacac0dae4e0 Mon Sep 17 00:00:00 2001 From: Andrew Mirsky Date: Mon, 26 May 2025 10:46:11 -0400 Subject: [PATCH] enhancing the 'test_init_handler' case so that it checks to make sure that the ProtocolHandler defaults to the correct loop. --- tests/mqtt/protocol/test_handler.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/mqtt/protocol/test_handler.py b/tests/mqtt/protocol/test_handler.py index e110c94..349016c 100644 --- a/tests/mqtt/protocol/test_handler.py +++ b/tests/mqtt/protocol/test_handler.py @@ -38,11 +38,23 @@ class ProtocolHandlerTest(unittest.TestCase): self.loop.close() def test_init_handler(self): - Session() - handler = ProtocolHandler(self.plugin_manager, loop=self.loop) - assert handler.session is None - assert handler._loop is self.loop - self.check_empty_waiters(handler) + + async def test_coro() -> None: + try: + Session() + handler = ProtocolHandler(self.plugin_manager) + assert handler.session is None + assert handler._loop is self.loop + self.check_empty_waiters(handler) + future.set_result(True) + except Exception as ae: + future.set_exception(ae) + + future: asyncio.Future[Any] = asyncio.Future() + self.loop.run_until_complete(test_coro()) + exception = future.exception() + if exception: + raise exception def test_start_stop(self): async def server_mock(reader, writer) -> None: