Skip to content

Commit d0225df

Browse files
author
g97iulio1609
committed
test: cover find_context_parameter with non-callable input
Exercise the branch in context_injection.py where the input is neither a function/method nor a callable class, ensuring 100% branch coverage.
1 parent 578769a commit d0225df

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/server/mcpserver/test_tool_manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ async def __call__(self, x: int, ctx: Context[ServerSessionT, None]) -> str:
449449
result = await manager.call_tool("my_tool", {"x": 42}, context=ctx)
450450
assert result == "42"
451451

452+
def test_find_context_parameter_non_callable(self):
453+
"""Test find_context_parameter returns None for non-callable objects."""
454+
from mcp.server.mcpserver.utilities.context_injection import find_context_parameter
455+
456+
result = find_context_parameter(42) # type: ignore[arg-type]
457+
assert result is None
458+
452459

453460
class TestToolAnnotations:
454461
def test_tool_annotations(self):

0 commit comments

Comments
 (0)