Skip to content

Commit 375e862

Browse files
committed
fix: add pragma markers for unreachable defensive branches in context_aware handler
- Add pragma: no branch for ctx.request guards (always truthy in test env) - Add pragma: no cover for unknown tool fallback return (never reached in tests) - Fixes coverage failure: these branches are defensive code paths that cannot be exercised through the test fixtures
1 parent f53793d commit 375e862

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/shared/test_streamable_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ async def _handle_context_call_tool(ctx: ServerRequestContext, params: CallToolR
14941494

14951495
if name == "echo_headers":
14961496
headers_info: dict[str, Any] = {}
1497-
if ctx.request and isinstance(ctx.request, Request):
1497+
if ctx.request and isinstance(ctx.request, Request): # pragma: no branch
14981498
headers_info = dict(ctx.request.headers)
14991499
return CallToolResult(content=[TextContent(type="text", text=json.dumps(headers_info))])
15001500

@@ -1505,14 +1505,14 @@ async def _handle_context_call_tool(ctx: ServerRequestContext, params: CallToolR
15051505
"method": None,
15061506
"path": None,
15071507
}
1508-
if ctx.request and isinstance(ctx.request, Request):
1508+
if ctx.request and isinstance(ctx.request, Request): # pragma: no branch
15091509
request = ctx.request
15101510
context_data["headers"] = dict(request.headers)
15111511
context_data["method"] = request.method
15121512
context_data["path"] = request.url.path
15131513
return CallToolResult(content=[TextContent(type="text", text=json.dumps(context_data))])
15141514

1515-
return CallToolResult(content=[TextContent(type="text", text=f"Unknown tool: {name}")])
1515+
return CallToolResult(content=[TextContent(type="text", text=f"Unknown tool: {name}")]) # pragma: no cover
15161516

15171517

15181518
# Server runner for context-aware testing

0 commit comments

Comments
 (0)