Skip to content

Commit

Permalink
Bugs in coverage were fixed \o/
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Aug 3, 2024
1 parent fab77d6 commit 14cca76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/websockets/legacy/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion tests/legacy/test_client_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 6 additions & 12 deletions tests/legacy/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand All @@ -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",
)
Expand All @@ -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,
"",
)
Expand All @@ -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,
"",
)
Expand All @@ -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",
)
Expand All @@ -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",
)

0 comments on commit 14cca76

Please sign in to comment.