mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
added unit testing for multi-line output
This commit is contained in:
@@ -36,3 +36,18 @@ class TestCodeInterpreterTool(unittest.TestCase):
|
|||||||
result = tool.run_code_in_docker(code, libraries_used)
|
result = tool.run_code_in_docker(code, libraries_used)
|
||||||
|
|
||||||
self.assertEqual(result, expected_output)
|
self.assertEqual(result, expected_output)
|
||||||
|
|
||||||
|
@patch("crewai_tools.tools.code_interpreter_tool.code_interpreter_tool.docker_from_env")
|
||||||
|
def test_run_code_in_docker_with_script(self, docker_mock):
|
||||||
|
tool = CodeInterpreterTool()
|
||||||
|
code = """print("This is line 1")
|
||||||
|
print("This is line 2")"""
|
||||||
|
libraries_used = [] # No additional libraries needed for this test
|
||||||
|
expected_output = "This is line 1\nThis is line 2\n"
|
||||||
|
|
||||||
|
# Mock Docker responses
|
||||||
|
docker_mock().containers.run().exec_run().exit_code = 0
|
||||||
|
docker_mock().containers.run().exec_run().output = expected_output.encode()
|
||||||
|
|
||||||
|
result = tool.run_code_in_docker(code, libraries_used)
|
||||||
|
self.assertEqual(result, expected_output)
|
||||||
|
|||||||
Reference in New Issue
Block a user