MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_call_tool_format_exception

Function test_call_tool_format_exception

tests/tools/test_dynamic_tools.py:427–452  ·  view source on GitHub ↗

Test call_tool handles format_tool_response exception.

()

Source from the content-addressed store, hash-verified

425
426@pytest.mark.asyncio
427async def test_call_tool_format_exception():
428 """Test call_tool handles format_tool_response exception."""
429 tools = [
430 ToolInfo(name="test", namespace="test", description="Test tool", parameters={}),
431 ]
432 tool_manager = DummyToolManager(tools)
433 tool_manager.execute_tool = AsyncMock(
434 return_value=ToolCallResult(
435 tool_name="test",
436 success=True,
437 result={"data": "test"},
438 )
439 )
440 # Make format_tool_response raise an exception
441 tool_manager.format_tool_response = lambda x: (_ for _ in ()).throw(
442 ValueError("format error")
443 )
444
445 provider = DynamicToolProvider(tool_manager)
446 # Must fetch schema first (enforced workflow)
447 await provider.get_tool_schema("test")
448 result = await provider.call_tool("test", {})
449
450 # Should fallback to str() representation
451 assert result["success"] is True
452 assert "result" in result
453
454
455@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 5

ToolInfoClass · 0.90
ToolCallResultClass · 0.90
DynamicToolProviderClass · 0.90
call_toolMethod · 0.80
DummyToolManagerClass · 0.70

Tested by

no test coverage detected