Skip to content

Commit 17a9dca

Browse files
committed
Give the stdio interaction test's child headroom for coverage shutdown
After shutdown closes the child's stdin, the child has to unwind its run loop, write its clean-exit stderr line, and let coverage's atexit hook persist the subprocess data file before the stdin-close grace expires. On a slow Windows runner the production 2s grace was too tight: the escalation killed the child mid-atexit - after the asserted stderr line, so the test stayed green - and the silently missing data file failed the 100% coverage gate at 99.95%. Widen the grace to 10s for this one test; the timeout is not under test here.
1 parent dbb885b commit 17a9dca

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/interaction/transports/test_stdio.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import pytest
2727
from inline_snapshot import snapshot
2828

29+
from mcp.client import stdio
2930
from mcp.client.client import Client
3031
from mcp.client.stdio import StdioServerParameters, stdio_client
3132
from mcp.server.stdio import stdio_server
@@ -51,10 +52,20 @@
5152
@requirement("transport:stdio")
5253
@requirement("transport:stdio:clean-shutdown")
5354
@requirement("transport:stdio:stderr-passthrough")
54-
async def test_tool_call_and_notification_round_trip_over_a_stdio_subprocess() -> None:
55+
async def test_tool_call_and_notification_round_trip_over_a_stdio_subprocess(
56+
monkeypatch: pytest.MonkeyPatch,
57+
) -> None:
5558
"""A Client connected over stdio initializes, calls a tool with arguments, receives the
5659
server's log notification before the call returns, and the server exits when the transport
5760
closes its stdin."""
61+
# After shutdown closes the child's stdin, the child must unwind its run loop, write the
62+
# clean-exit line asserted below, and let coverage's atexit hook persist the subprocess data
63+
# file (enabled by the COVERAGE_ passthrough below) before the grace period expires. The
64+
# production 2s default proved too tight on slow Windows runners: the escalation killed the
65+
# child mid-atexit — after the asserted stderr line, so the test stayed green — and the
66+
# silently missing data file tripped the 100% coverage gate. The timeout is not under test.
67+
monkeypatch.setattr(stdio, "PROCESS_TERMINATION_TIMEOUT", 10.0)
68+
5869
received: list[LoggingMessageNotificationParams] = []
5970

6071
async def collect(params: LoggingMessageNotificationParams) -> None:

0 commit comments

Comments
 (0)