Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test E2B Executor #540

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ jobs:
uv run pytest ./tests/test_local_python_executor.py
if: ${{ success() || failure() }}

- name: E2B executor tests
run: |
uv run pytest ./tests/test_e2b_executor.py
if: ${{ success() || failure() }}

- name: Search tests
run: |
uv run pytest ./tests/test_search.py
Expand Down
18 changes: 18 additions & 0 deletions tests/test_e2b_executor.py
Original file line number Diff line number Diff line change
@@ -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