Skip to content

Commit dd1ee3d

Browse files
test: let async-for loop exhaust to cover both branches
Remove time.sleep(1) so the child exits immediately after writing, then drop the early-break guard. The loop now terminates by exhaustion rather than break, which covers the previously-missing 532->537 branch and restores 100 % coverage.
1 parent a81b8c4 commit dd1ee3d

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

tests/client/test_stdio.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,10 @@ async def test_stdio_client_invalid_utf8():
512512
valid_line = '{"jsonrpc":"2.0","id":1,"method":"ping"}'
513513
script = textwrap.dedent(
514514
f"""
515-
import sys, time
515+
import sys
516516
sys.stdout.buffer.write(b"\\xff\\xfe\\n")
517517
sys.stdout.buffer.write({valid_line!r}.encode() + b"\\n")
518518
sys.stdout.buffer.flush()
519-
time.sleep(1)
520519
"""
521520
)
522521

@@ -531,8 +530,6 @@ async def test_stdio_client_invalid_utf8():
531530
async with stdio_client(server_params) as (read_stream, _write_stream):
532531
async for item in read_stream:
533532
items.append(item)
534-
if len(items) >= 2:
535-
break
536533

537534
assert len(items) == 2
538535
assert isinstance(items[0], Exception)

0 commit comments

Comments
 (0)