Test edit file tool.
()
| 51 | |
| 52 | @pytest.mark.asyncio |
| 53 | async def test_edit_tool(): |
| 54 | """Test edit file tool.""" |
| 55 | print("\n=== Testing EditTool ===") |
| 56 | |
| 57 | with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as f: |
| 58 | f.write("Hello, World!") |
| 59 | temp_path = f.name |
| 60 | |
| 61 | try: |
| 62 | tool = EditTool() |
| 63 | result = await tool.execute( |
| 64 | path=temp_path, old_str="World", new_str="Agent" |
| 65 | ) |
| 66 | |
| 67 | assert result.success, f"Edit failed: {result.error}" |
| 68 | content = Path(temp_path).read_text() |
| 69 | assert content == "Hello, Agent!", f"Content mismatch: {content}" |
| 70 | print("✅ EditTool test passed") |
| 71 | finally: |
| 72 | Path(temp_path).unlink() |
| 73 | |
| 74 | |
| 75 | @pytest.mark.asyncio |