Skip to content

Commit 901e434

Browse files
committed
Work around bug in coverage.
1 parent f075aac commit 901e434

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/websockets/legacy/protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,8 @@ async def close_transport(self) -> None:
13611361
# Abort the TCP connection. Buffers are discarded.
13621362
if self.debug:
13631363
self.logger.debug("x aborting TCP connection")
1364-
self.transport.abort()
1364+
# Due to a bug in coverage, this is erroneously reported as not covered.
1365+
self.transport.abort() # pragma: no cover
13651366

13661367
# connection_lost() is called quickly after aborting.
13671368
await self.wait_for_connection_lost()

tests/legacy/test_protocol.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,8 @@ def test_local_close_connection_lost_timeout_after_write_eof(self):
15791579
self.receive_frame(self.close_frame)
15801580
self.run_loop_once()
15811581
self.loop.run_until_complete(self.protocol.close(reason="close"))
1582-
self.assertConnectionClosed(1000, "close")
1582+
# Due to a bug in coverage, this is erroneously reported as not covered.
1583+
self.assertConnectionClosed(1000, "close") # pragma: no cover
15831584

15841585
def test_local_close_connection_lost_timeout_after_close(self):
15851586
self.protocol.close_timeout = 10 * MS
@@ -1596,7 +1597,8 @@ def test_local_close_connection_lost_timeout_after_close(self):
15961597
self.receive_frame(self.close_frame)
15971598
self.run_loop_once()
15981599
self.loop.run_until_complete(self.protocol.close(reason="close"))
1599-
self.assertConnectionClosed(1000, "close")
1600+
# Due to a bug in coverage, this is erroneously reported as not covered.
1601+
self.assertConnectionClosed(1000, "close") # pragma: no cover
16001602

16011603

16021604
class ClientTests(CommonTests, AsyncioTestCase):
@@ -1614,7 +1616,8 @@ def test_local_close_send_close_frame_timeout(self):
16141616
# Check the timing within -1/+9ms for robustness.
16151617
with self.assertCompletesWithin(19 * MS, 29 * MS):
16161618
self.loop.run_until_complete(self.protocol.close(reason="close"))
1617-
self.assertConnectionClosed(1006, "")
1619+
# Due to a bug in coverage, this is erroneously reported as not covered.
1620+
self.assertConnectionClosed(1006, "") # pragma: no cover
16181621

16191622
def test_local_close_receive_close_frame_timeout(self):
16201623
self.protocol.close_timeout = 10 * MS
@@ -1624,7 +1627,8 @@ def test_local_close_receive_close_frame_timeout(self):
16241627
# Check the timing within -1/+9ms for robustness.
16251628
with self.assertCompletesWithin(19 * MS, 29 * MS):
16261629
self.loop.run_until_complete(self.protocol.close(reason="close"))
1627-
self.assertConnectionClosed(1006, "")
1630+
# Due to a bug in coverage, this is erroneously reported as not covered.
1631+
self.assertConnectionClosed(1006, "") # pragma: no cover
16281632

16291633
def test_local_close_connection_lost_timeout_after_write_eof(self):
16301634
self.protocol.close_timeout = 10 * MS
@@ -1639,7 +1643,8 @@ def test_local_close_connection_lost_timeout_after_write_eof(self):
16391643
self.receive_frame(self.close_frame)
16401644
self.run_loop_once()
16411645
self.loop.run_until_complete(self.protocol.close(reason="close"))
1642-
self.assertConnectionClosed(1000, "close")
1646+
# Due to a bug in coverage, this is erroneously reported as not covered.
1647+
self.assertConnectionClosed(1000, "close") # pragma: no cover
16431648

16441649
def test_local_close_connection_lost_timeout_after_close(self):
16451650
self.protocol.close_timeout = 10 * MS
@@ -1659,4 +1664,5 @@ def test_local_close_connection_lost_timeout_after_close(self):
16591664
self.receive_frame(self.close_frame)
16601665
self.run_loop_once()
16611666
self.loop.run_until_complete(self.protocol.close(reason="close"))
1662-
self.assertConnectionClosed(1000, "close")
1667+
# Due to a bug in coverage, this is erroneously reported as not covered.
1668+
self.assertConnectionClosed(1000, "close") # pragma: no cover

0 commit comments

Comments
 (0)