fix: added configuration of python_repl (#503)

* fix: added configuration of python_repl

* fix the lint and unit test errors

* fix the lint and unit test errors

* fix:the lint check errors
This commit is contained in:
Willem Jiang
2025-08-06 14:27:03 +08:00
committed by GitHub
parent 4218cddab5
commit 9e691ecf20
11 changed files with 194 additions and 77 deletions

View File

@@ -1,59 +0,0 @@
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
from src.tools.python_repl import python_repl_tool
def test_python_repl_tool_success():
code = "print(1 + 1)"
result = python_repl_tool(code)
assert "Successfully executed" in result
assert "Stdout: 2" in result
def test_python_repl_tool_syntax_error():
code = "print(1 + )"
result = python_repl_tool(code)
assert "Error executing code:" in result
assert code in result
assert "SyntaxError" in result
def test_python_repl_tool_runtime_error():
code = "print(1 / 0)"
result = python_repl_tool(code)
assert "Error executing code:" in result
assert code in result
assert "ZeroDivisionError" in result
def test_python_repl_tool_name_error():
code = "print(undefined_variable)"
result = python_repl_tool(code)
assert "Error executing code:" in result
assert code in result
assert "NameError" in result
def test_python_repl_tool_type_error():
code = "'2' + 2"
result = python_repl_tool(code)
assert "Error executing code:" in result
assert code in result
assert "TypeError" in result
def test_python_repl_tool_import_error():
code = "from nonexistent_module import something"
result = python_repl_tool(code)
assert "Error executing code:" in result
assert code in result
assert "ModuleNotFoundError" in result
def test_python_repl_tool_exception():
code = "raise Exception('Test')"
result = python_repl_tool(code)
assert "Error executing code:" in result
assert code in result
assert "Exception" in result