Skip to content

Commit 99709b8

Browse files
committed
fix(test-e2b-output): mark E2B stub modules as packages with __path__
1 parent 570d4b4 commit 99709b8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/scripts/test_e2b_run_validation_output.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def _install_e2b_stubs(monkeypatch) -> None:
1616
commands_module = ModuleType("e2b.sandbox.commands")
1717
command_handle_module = ModuleType("e2b.sandbox.commands.command_handle")
1818
interpreter_module = ModuleType("e2b_code_interpreter")
19+
e2b_module.__path__ = []
20+
sandbox_module.__path__ = []
21+
commands_module.__path__ = []
1922

2023
class CommandExitException(Exception):
2124
exit_code = 1
@@ -42,6 +45,17 @@ def create(cls, **_kwargs):
4245
monkeypatch.setitem(sys.modules, "e2b_code_interpreter", interpreter_module)
4346

4447

48+
def test_e2b_stubs_support_nested_command_handle_import(monkeypatch) -> None:
49+
_install_e2b_stubs(monkeypatch)
50+
51+
command_handle = importlib.import_module("e2b.sandbox.commands.command_handle")
52+
53+
assert sys.modules["e2b"].__path__ == []
54+
assert sys.modules["e2b.sandbox"].__path__ == []
55+
assert sys.modules["e2b.sandbox.commands"].__path__ == []
56+
assert command_handle.CommandExitException.__name__ == "CommandExitException"
57+
58+
4559
def _load_run_validation(monkeypatch):
4660
_install_e2b_stubs(monkeypatch)
4761
monkeypatch.syspath_prepend(str(E2B_SCRIPT_DIR))

0 commit comments

Comments
 (0)