Test call_tool handles format_tool_response exception.
()
| 425 | |
| 426 | @pytest.mark.asyncio |
| 427 | async 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 |
nothing calls this directly
no test coverage detected