@@ -715,20 +715,21 @@ async def test_websocket_connection_closed(init_gateway, jp_serverapp, jp_fetch,
715715 handler .ws_connection .is_closing = lambda : True
716716
717717 # Create the GatewayWebSocketConnection and attach it to the handler...
718- conn = GatewayWebSocketConnection (parent = km , websocket_handler = handler )
719- handler .connection = conn
720- await conn .connect ()
721-
722- # Processing websocket messages happens in separate coroutines and any
723- # errors in that process will show up in logs, but not bubble up to the
724- # caller.
725- #
726- # To check for these, we wait for the server to stop and then check the
727- # logs for errors.
728- await jp_serverapp ._cleanup ()
729- for _ , level , message in caplog .record_tuples :
730- if level >= logging .ERROR :
731- pytest .fail (f"Logs contain an error: { message } " )
718+ with mocked_gateway :
719+ conn = GatewayWebSocketConnection (parent = km , websocket_handler = handler )
720+ handler .connection = conn
721+ await conn .connect ()
722+
723+ # Processing websocket messages happens in separate coroutines and any
724+ # errors in that process will show up in logs, but not bubble up to the
725+ # caller.
726+ #
727+ # To check for these, we wait for the server to stop and then check the
728+ # logs for errors.
729+ await jp_serverapp ._cleanup ()
730+ for _ , level , message in caplog .record_tuples :
731+ if level >= logging .ERROR :
732+ pytest .fail (f"Logs contain an error: { message } " )
732733
733734
734735#
0 commit comments