diff --git a/src/websockets/legacy/protocol.py b/src/websockets/legacy/protocol.py index 3d09440e..de9ea59b 100644 --- a/src/websockets/legacy/protocol.py +++ b/src/websockets/legacy/protocol.py @@ -1349,8 +1349,7 @@ async def close_transport(self) -> None: # Abort the TCP connection. Buffers are discarded. if self.debug: self.logger.debug("x aborting TCP connection") - # Due to a bug in coverage, this is erroneously reported as not covered. - self.transport.abort() # pragma: no cover + self.transport.abort() # connection_lost() is called quickly after aborting. await self.wait_for_connection_lost() diff --git a/tests/legacy/test_client_server.py b/tests/legacy/test_client_server.py index 09b3b361..0c3f2215 100644 --- a/tests/legacy/test_client_server.py +++ b/tests/legacy/test_client_server.py @@ -1584,7 +1584,6 @@ async def run_client(): else: # Exit block with an exception. raise Exception("BOOM") - pass # work around bug in coverage with self.assertLogs("websockets", logging.INFO) as logs: with self.assertRaises(Exception) as raised: diff --git a/tests/legacy/test_protocol.py b/tests/legacy/test_protocol.py index 05d2f379..d6303dcc 100644 --- a/tests/legacy/test_protocol.py +++ b/tests/legacy/test_protocol.py @@ -1613,8 +1613,7 @@ def test_local_close_connection_lost_timeout_after_write_eof(self): self.receive_frame(self.close_frame) self.run_loop_once() self.loop.run_until_complete(self.protocol.close(reason="close")) - # Due to a bug in coverage, this is erroneously reported as not covered. - self.assertConnectionClosed( # pragma: no cover + self.assertConnectionClosed( CloseCode.NORMAL_CLOSURE, "close", ) @@ -1634,8 +1633,7 @@ def test_local_close_connection_lost_timeout_after_close(self): self.receive_frame(self.close_frame) self.run_loop_once() self.loop.run_until_complete(self.protocol.close(reason="close")) - # Due to a bug in coverage, this is erroneously reported as not covered. - self.assertConnectionClosed( # pragma: no cover + self.assertConnectionClosed( CloseCode.NORMAL_CLOSURE, "close", ) @@ -1656,8 +1654,7 @@ def test_local_close_send_close_frame_timeout(self): # Check the timing within -1/+9ms for robustness. with self.assertCompletesWithin(19 * MS, 29 * MS): self.loop.run_until_complete(self.protocol.close(reason="close")) - # Due to a bug in coverage, this is erroneously reported as not covered. - self.assertConnectionClosed( # pragma: no cover + self.assertConnectionClosed( CloseCode.ABNORMAL_CLOSURE, "", ) @@ -1670,8 +1667,7 @@ def test_local_close_receive_close_frame_timeout(self): # Check the timing within -1/+9ms for robustness. with self.assertCompletesWithin(19 * MS, 29 * MS): self.loop.run_until_complete(self.protocol.close(reason="close")) - # Due to a bug in coverage, this is erroneously reported as not covered. - self.assertConnectionClosed( # pragma: no cover + self.assertConnectionClosed( CloseCode.ABNORMAL_CLOSURE, "", ) @@ -1689,8 +1685,7 @@ def test_local_close_connection_lost_timeout_after_write_eof(self): self.receive_frame(self.close_frame) self.run_loop_once() self.loop.run_until_complete(self.protocol.close(reason="close")) - # Due to a bug in coverage, this is erroneously reported as not covered. - self.assertConnectionClosed( # pragma: no cover + self.assertConnectionClosed( CloseCode.NORMAL_CLOSURE, "close", ) @@ -1713,8 +1708,7 @@ def test_local_close_connection_lost_timeout_after_close(self): self.receive_frame(self.close_frame) self.run_loop_once() self.loop.run_until_complete(self.protocol.close(reason="close")) - # Due to a bug in coverage, this is erroneously reported as not covered. - self.assertConnectionClosed( # pragma: no cover + self.assertConnectionClosed( CloseCode.NORMAL_CLOSURE, "close", )