@@ -638,7 +638,7 @@ def get_scores() -> dict[str, int]:
638638class TestRemoveTools :
639639 """Test tool removal functionality in the tool manager."""
640640
641- def test_remove_existing_tool (self , caplog : pytest . LogCaptureFixture ):
641+ def test_remove_existing_tool (self ):
642642 """Test removing an existing tool."""
643643
644644 def add (a : int , b : int ) -> int :
@@ -652,23 +652,19 @@ def add(a: int, b: int) -> int:
652652 assert manager .get_tool ("add" ) is not None
653653 assert len (manager .list_tools ()) == 1
654654
655- # Remove the tool
656- with caplog .at_level (logging .WARNING ):
657- manager .remove_tool ("add" )
658- # Should not log a warning for removing existing tool
659- assert "Tried to remove unknown tool: add" not in caplog .text
655+ # Remove the tool - should not raise any exception
656+ manager .remove_tool ("add" )
660657
661658 # Verify tool is removed
662659 assert manager .get_tool ("add" ) is None
663660 assert len (manager .list_tools ()) == 0
664661
665- def test_remove_nonexistent_tool (self , caplog : pytest . LogCaptureFixture ):
666- """Test removing a non-existent tool logs a warning ."""
662+ def test_remove_nonexistent_tool (self ):
663+ """Test removing a non-existent tool raises ToolError ."""
667664 manager = ToolManager ()
668665
669- with caplog . at_level ( logging . WARNING ):
666+ with pytest . raises ( ToolError , match = "Unknown tool: nonexistent" ):
670667 manager .remove_tool ("nonexistent" )
671- assert "Tried to remove unknown tool: nonexistent" in caplog .text
672668
673669 def test_remove_tool_from_multiple_tools (self ):
674670 """Test removing one tool when multiple tools exist."""
@@ -727,7 +723,7 @@ def greet(name: str) -> str:
727723 with pytest .raises (ToolError , match = "Unknown tool: greet" ):
728724 await manager .call_tool ("greet" , {"name" : "World" })
729725
730- def test_remove_tool_case_sensitive (self , caplog : pytest . LogCaptureFixture ):
726+ def test_remove_tool_case_sensitive (self ):
731727 """Test that tool removal is case-sensitive."""
732728
733729 def test_func () -> str :
@@ -740,10 +736,9 @@ def test_func() -> str:
740736 # Verify tool exists
741737 assert manager .get_tool ("test_func" ) is not None
742738
743- # Try to remove with different case
744- with caplog . at_level ( logging . WARNING ):
739+ # Try to remove with different case - should raise ToolError
740+ with pytest . raises ( ToolError , match = "Unknown tool: Test_Func" ):
745741 manager .remove_tool ("Test_Func" )
746- assert "Tried to remove unknown tool: Test_Func" in caplog .text
747742
748743 # Verify original tool still exists
749744 assert manager .get_tool ("test_func" ) is not None
0 commit comments