mirror of
https://github.com/hwchase17/langchain.git
synced 2026-01-15 23:27:07 +00:00
Fix Python RePL Tool (#4137)
Filter out kwargs from inferred schema when determining if a tool is single input. Add a couple unit tests. Move tool unit tests to the tools dir
This commit is contained in:
23
tests/unit_tests/tools/python/test_python.py
Normal file
23
tests/unit_tests/tools/python/test_python.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""Test Python REPL Tools."""
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from langchain.tools.python.tool import PythonAstREPLTool, PythonREPLTool
|
||||
|
||||
|
||||
def test_python_repl_tool_single_input() -> None:
|
||||
"""Test that the python REPL tool works with a single input."""
|
||||
tool = PythonREPLTool()
|
||||
assert tool.is_single_input
|
||||
assert int(tool.run("print(1 + 1)").strip()) == 2
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info < (3, 9), reason="Requires python version >= 3.9 to run."
|
||||
)
|
||||
def test_python_ast_repl_tool_single_input() -> None:
|
||||
"""Test that the python REPL tool works with a single input."""
|
||||
tool = PythonAstREPLTool()
|
||||
assert tool.is_single_input
|
||||
assert tool.run("1 + 1") == 2
|
||||
Reference in New Issue
Block a user