Skip to content

Commit 0a8f0f4

Browse files
committed
test: address 3.11/3.14 coverage instrumentation quirks
3.14: nested async-with arc misreporting on three create_task_group lines (the documented AGENTS.md case) — pragma: no branch. 3.11: lines after async-CM exit with pytest.raises mis-traced in one test — moved the asserts inside the context manager.
1 parent cffb527 commit 0a8f0f4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

tests/shared/test_dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ async def on_request(
208208
async with running_pair(direct_pair, server_on_request=on_request) as (client, *_):
209209
with anyio.fail_after(5), pytest.raises(MCPError) as exc:
210210
await client.send_raw_request("tools/list", {})
211-
assert exc.value.error.code == INTERNAL_ERROR
212-
assert isinstance(exc.value.__cause__, ValueError)
211+
assert exc.value.error.code == INTERNAL_ERROR
212+
assert isinstance(exc.value.__cause__, ValueError)
213213

214214

215215
@pytest.mark.anyio

tests/shared/test_jsonrpc_dispatcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async def call(method: str) -> None:
5656
results[method] = await client.send_request(method, None)
5757

5858
with anyio.fail_after(5):
59-
async with anyio.create_task_group() as tg:
59+
async with anyio.create_task_group() as tg: # pragma: no branch
6060
tg.start_soon(call, "first")
6161
await anyio.sleep(0)
6262
tg.start_soon(call, "second")
@@ -99,7 +99,7 @@ async def server_on_request(ctx: DCtx, method: str, params: Mapping[str, Any] |
9999

100100
async with running_pair(jsonrpc_pair, server_on_request=server_on_request) as (client, *_):
101101
with anyio.fail_after(5):
102-
async with anyio.create_task_group() as tg:
102+
async with anyio.create_task_group() as tg: # pragma: no branch
103103

104104
async def call_then_record() -> None:
105105
with pytest.raises(MCPError): # we'll cancel via tg below
@@ -137,7 +137,7 @@ def factory(*, can_send_request: bool = True):
137137
result_box: list[dict[str, Any]] = []
138138
async with running_pair(factory, server_on_request=server_on_request) as (client, *_):
139139
with anyio.fail_after(5):
140-
async with anyio.create_task_group() as tg:
140+
async with anyio.create_task_group() as tg: # pragma: no branch
141141

142142
async def call() -> None:
143143
result_box.append(await client.send_request("slow", None))

0 commit comments

Comments
 (0)