Skip to content

Commit b8fe469

Browse files
author
skyvanguard
committed
fix: add coverage pragmas for non-deterministic test paths
ASGITransport timeout behavior is non-deterministic in CI with parallel execution, making except clauses unreliable to cover. The ValueError guard is defensive code never triggered in tests. Github-Issue:#1648
1 parent 46862dd commit b8fe469

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/issues/test_1648_client_disconnect_500.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def handle_call_tool(name: str, arguments: dict[str, object]) -> list[Text
4646
if name == "slow_tool":
4747
await anyio.sleep(10)
4848
return [TextContent(type="text", text="done")]
49-
raise ValueError(f"Unknown tool: {name}")
49+
raise ValueError(f"Unknown tool: {name}") # pragma: no cover
5050

5151

5252
def create_app() -> Starlette:
@@ -125,7 +125,7 @@ async def test_client_disconnect_does_not_produce_500(caplog: pytest.LogCaptureF
125125
"Content-Type": "application/json",
126126
},
127127
)
128-
except (httpx.ReadTimeout, httpx.ReadError):
128+
except (httpx.ReadTimeout, httpx.ReadError): # pragma: no cover
129129
pass # Expected - client timed out
130130

131131
# Wait briefly for any async error logging to complete
@@ -171,7 +171,7 @@ async def test_server_healthy_after_client_disconnect():
171171
"Content-Type": "application/json",
172172
},
173173
)
174-
except (httpx.ReadTimeout, httpx.ReadError):
174+
except (httpx.ReadTimeout, httpx.ReadError): # pragma: no cover
175175
pass # Expected - client timed out
176176

177177
# Create a new client for the second request

0 commit comments

Comments
 (0)