import tempfile import unittest from pathlib import Path from tools.run_python import RunPythonTool class RunPythonScriptPathTests(unittest.TestCase): def test_executes_existing_script_path(self) -> None: with tempfile.TemporaryDirectory() as tmp: script = Path(tmp) / "hello.py" script.write_text("print('hello from file')\n", encoding="utf-8") out = RunPythonTool(base_dir=tmp).execute(script_path="hello.py") self.assertIn("[stdout]\nhello from file", out) self.assertIn("[exit 0]", out) def test_requires_code_or_script_path(self) -> None: out = RunPythonTool().execute() self.assertIn("[Error]", out) self.assertIn("code or script_path", out) if __name__ == "__main__": unittest.main()