Test E2B Executor (#540)

This commit is contained in:
Albert Villanova del Moral 2025-02-07 15:51:14 +01:00 committed by GitHub
parent ec66b56550
commit 823b8df0fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View File

@ -78,6 +78,11 @@ jobs:
uv run pytest ./tests/test_local_python_executor.py uv run pytest ./tests/test_local_python_executor.py
if: ${{ success() || failure() }} if: ${{ success() || failure() }}
- name: E2B executor tests
run: |
uv run pytest ./tests/test_e2b_executor.py
if: ${{ success() || failure() }}
- name: Search tests - name: Search tests
run: | run: |
uv run pytest ./tests/test_search.py uv run pytest ./tests/test_search.py

View File

@ -0,0 +1,18 @@
from unittest.mock import MagicMock, patch
from smolagents.e2b_executor import E2BExecutor
class TestE2BExecutor:
def test_e2b_executor_instantiation(self):
logger = MagicMock()
with patch("e2b_code_interpreter.Sandbox") as mock_sandbox:
mock_sandbox.return_value.commands.run.return_value.error = None
mock_sandbox.return_value.run_code.return_value.error = None
executor = E2BExecutor(additional_imports=[], tools=[], logger=logger)
assert isinstance(executor, E2BExecutor)
assert executor.logger == logger
assert executor.final_answer is False
assert executor.custom_tools == {}
assert executor.final_answer_pattern.pattern == r"final_answer\((.*?)\)"
assert executor.sbx == mock_sandbox.return_value