@@ -638,7 +638,7 @@ def get_scores() -> dict[str, int]:
638
638
class TestRemoveTools :
639
639
"""Test tool removal functionality in the tool manager."""
640
640
641
- def test_remove_existing_tool (self , caplog : pytest . LogCaptureFixture ):
641
+ def test_remove_existing_tool (self ):
642
642
"""Test removing an existing tool."""
643
643
644
644
def add (a : int , b : int ) -> int :
@@ -652,23 +652,19 @@ def add(a: int, b: int) -> int:
652
652
assert manager .get_tool ("add" ) is not None
653
653
assert len (manager .list_tools ()) == 1
654
654
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" )
660
657
661
658
# Verify tool is removed
662
659
assert manager .get_tool ("add" ) is None
663
660
assert len (manager .list_tools ()) == 0
664
661
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 ."""
667
664
manager = ToolManager ()
668
665
669
- with caplog . at_level ( logging . WARNING ):
666
+ with pytest . raises ( ToolError , match = "Unknown tool: nonexistent" ):
670
667
manager .remove_tool ("nonexistent" )
671
- assert "Tried to remove unknown tool: nonexistent" in caplog .text
672
668
673
669
def test_remove_tool_from_multiple_tools (self ):
674
670
"""Test removing one tool when multiple tools exist."""
@@ -727,7 +723,7 @@ def greet(name: str) -> str:
727
723
with pytest .raises (ToolError , match = "Unknown tool: greet" ):
728
724
await manager .call_tool ("greet" , {"name" : "World" })
729
725
730
- def test_remove_tool_case_sensitive (self , caplog : pytest . LogCaptureFixture ):
726
+ def test_remove_tool_case_sensitive (self ):
731
727
"""Test that tool removal is case-sensitive."""
732
728
733
729
def test_func () -> str :
@@ -740,10 +736,9 @@ def test_func() -> str:
740
736
# Verify tool exists
741
737
assert manager .get_tool ("test_func" ) is not None
742
738
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" ):
745
741
manager .remove_tool ("Test_Func" )
746
- assert "Tried to remove unknown tool: Test_Func" in caplog .text
747
742
748
743
# Verify original tool still exists
749
744
assert manager .get_tool ("test_func" ) is not None
0 commit comments