Skip to content

Commit fe1f248

Browse files
committed
Move assertions inside with-block to satisfy coverage.py on 3.11
The test passes on all versions, but coverage.py on 3.11 misreports the statements after a `with a, b:` + nested `async with` exit as unhit. Claude-Session: https://claude.ai/code/session_017S3aJaxEHeMvftp6whnHWK
1 parent 06d1492 commit fe1f248

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+
# Assertions inside the with-block: coverage.py on 3.11 misreports lines after
187+
# a `with a, b:` + nested `async with` exit as unhit even when they run.
188+
assert response.status_code == 200
189+
assert response.json()["result"]["tools"] == []
190+
assert "abandoning remaining callbacks" in caplog.text

0 commit comments

Comments
 (0)