Skip to content

Commit 85ef45a

Browse files
committed
test: use receive() and no-branch pragma for nested async with
coverage.py misreports the ->exit arc on nested async with on Python 3.14 Windows. Also simplify from __aiter__/__anext__ to receive().
1 parent 6139dff commit 85ef45a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/server/test_stdio.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,12 @@ async def test_stdio_server_invalid_utf8(monkeypatch: pytest.MonkeyPatch):
8383
with anyio.fail_after(5):
8484
async with stdio_server() as (read_stream, write_stream):
8585
await write_stream.aclose()
86-
async with read_stream:
87-
it = read_stream.__aiter__()
88-
86+
async with read_stream: # pragma: no branch
8987
# First line: \xff\xfe -> U+FFFD U+FFFD -> JSON parse fails -> exception in stream
90-
first = await it.__anext__()
88+
first = await read_stream.receive()
9189
assert isinstance(first, Exception)
9290

9391
# Second line: valid message still comes through
94-
second = await it.__anext__()
92+
second = await read_stream.receive()
9593
assert isinstance(second, SessionMessage)
9694
assert second.message == JSONRPCMessage(root=valid)

0 commit comments

Comments
 (0)