Skip to content

Commit ee0cd25

Browse files
committed
Clean up coverage pragmas
1 parent 60ecb14 commit ee0cd25

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/trio/_tests/test_subprocess.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,8 @@ async def test_shells_killed_by_default() -> None:
786786

787787
with trio.fail_after(1):
788788
with trio.open_signal_receiver(signal.SIGHUP) as signal_aiter: # type: ignore[attr-defined,unused-ignore]
789-
async for signum in signal_aiter: # pragma: no branch
790-
assert signum == signal.SIGHUP # type: ignore[attr-defined,unused-ignore]
791-
break
789+
signum = await signal_aiter.__anext__()
790+
assert signum == signal.SIGHUP # type: ignore[attr-defined,unused-ignore]
792791

793792
nursery.cancel_scope.cancel()
794793

@@ -807,10 +806,14 @@ async def test_shells_killed_by_default() -> None:
807806
# won't reap zombie children, so we have to work around that
808807
with pytest.raises(FileNotFoundError):
809808
with open(f"/proc/{child_pid}/status") as f: # noqa: ASYNC230
810-
for line in f: # pragma: no branch
809+
hit_zombie = False
810+
for line in f:
811811
if line.startswith("State:"):
812812
assert "Z" in line
813-
raise FileNotFoundError
813+
hit_zombie = True
814+
815+
if hit_zombie:
816+
raise FileNotFoundError
814817
else:
815818
with pytest.raises(OSError, match="No such process"):
816819
os.kill(child_pid, 0)
@@ -842,8 +845,7 @@ async def test_process_group_SIGKILL_escalation(mock_clock: MockClock) -> None:
842845

843846
with trio.fail_after(1):
844847
with trio.open_signal_receiver(signal.SIGHUP) as signal_aiter: # type: ignore[attr-defined,unused-ignore]
845-
async for signum in signal_aiter: # pragma: no branch
846-
assert signum == signal.SIGHUP # type: ignore[attr-defined,unused-ignore]
847-
break
848+
signum = await signal_aiter.__anext__()
849+
assert signum == signal.SIGHUP # type: ignore[attr-defined,unused-ignore]
848850

849851
nursery.cancel_scope.cancel()

0 commit comments

Comments
 (0)