Skip to content

Commit 7fc28eb

Browse files
committed
Exempt the new nested async with lines from branch coverage on 3.14
The 3.14 jobs failed the 100% gate while every other version passed. Both files were at 100% statement coverage; the shortfall was two partial branches, one per file, on the `async with stdio_client(...)` line nested inside `anyio.fail_after(...)`. On 3.14 the tracer records a self-arc for that line instead of the arcs into the body and out past the enclosing block, so both declared exits read as missing even though the body demonstrably runs. Same code and same tests measure 100% on 3.13. This is the existing convention here: test_lifecycle.py already carries `# pragma: no branch` on an identical `stdio_client` line, and the repo uses the pragma in 232 places, including one that names the same cause.
1 parent c900b53 commit 7fc28eb

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

tests/client/test_stdio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,8 @@ async def test_a_closed_errlog_stops_stderr_forwarding_without_failing_the_sessi
10331033

10341034
with caplog.at_level(logging.DEBUG, logger="mcp.client.stdio"):
10351035
with anyio.fail_after(5):
1036-
async with stdio_client(FAKE_PARAMS, errlog=cast(TextIO, errlog)) as (read_stream, _):
1036+
# no branch: coverage mis-traces the exit arcs of a nested `async with` on 3.14.
1037+
async with stdio_client(FAKE_PARAMS, errlog=cast(TextIO, errlog)) as (read_stream, _): # pragma: no branch
10371038
await process.feed_stderr(b"server diagnostics no one will read\n")
10381039
await errlog.attempted.wait()
10391040

tests/transports/stdio/test_lifecycle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ async def test_server_stderr_output_reaches_an_errlog_without_a_file_descriptor(
238238
# The bound covers one interpreter cold start on a loaded runner; a
239239
# healthy run takes well under a second.
240240
with anyio.fail_after(10.0):
241-
async with stdio_client(params, errlog=errlog):
241+
# no branch: coverage mis-traces the exit arcs of a nested `async with` on 3.14.
242+
async with stdio_client(params, errlog=errlog): # pragma: no branch
242243
stream = await accept_alive(sock)
243244
stack.push_async_callback(stream.aclose)
244245

0 commit comments

Comments
 (0)