Skip to content

Commit 4378d15

Browse files
committed
Mark post-shielded-cancel assertions as lax-no-cover for 3.11
The exit-stack-hangs test passes on all Python versions, but coverage.py on 3.11 misreports the assertions after the shielded move_on_after cancellation as unhit (the tracer in the test frame is disrupted by the cancel inside the request task). lax no cover is the sanctioned exclusion for lines covered on some versions but not others. Claude-Session: https://claude.ai/code/session_017S3aJaxEHeMvftp6whnHWK
1 parent 06d1492 commit 4378d15

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tests/server/test_experimental_streamable_http_modern.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ async def list_tools(ctx: ServerRequestContext, params: PaginatedRequestParams |
183183
with anyio.fail_after(5), caplog.at_level(logging.WARNING, logger=modern.__name__):
184184
async with _asgi_client(Server("test", on_list_tools=list_tools)) as http:
185185
response = await http.post("/mcp", json=_list_tools_body(), headers={"content-type": "application/json"})
186-
187-
assert response.status_code == 200
188-
assert response.json()["result"]["tools"] == []
189-
assert "abandoning remaining callbacks" in caplog.text
186+
# coverage.py on Python 3.11 misreports the lines below as unhit (the test passes there);
187+
# the shielded-cancel path inside the request task disrupts the tracer in this frame.
188+
assert response.status_code == 200 # pragma: lax no cover
189+
assert response.json()["result"]["tools"] == [] # pragma: lax no cover
190+
assert "abandoning remaining callbacks" in caplog.text # pragma: lax no cover

0 commit comments

Comments
 (0)