MCPcopy Create free account
hub / github.com/bcefghj/miniClaudeCode / TestGrepTool

Class TestGrepTool

tests/test_tools.py:169–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167
168
169class TestGrepTool(unittest.TestCase):
170 def setUp(self):
171 self.tool = GrepTool()
172
173 def test_search_in_file(self):
174 with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
175 f.write("def hello():\n return 'world'\n")
176 f.flush()
177 result = self.tool.execute({"pattern": "hello", "path": f.name})
178 self.assertFalse(result.is_error)
179 self.assertIn("hello", result.output)
180 Path(f.name).unlink()
181
182 def test_no_matches(self):
183 with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
184 f.write("nothing here\n")
185 f.flush()
186 result = self.tool.execute({"pattern": "zzzzz", "path": f.name})
187 self.assertIn("No matches", result.output)
188 Path(f.name).unlink()
189
190
191if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected