File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
4559def _load_run_validation (monkeypatch ):
4660 _install_e2b_stubs (monkeypatch )
4761 monkeypatch .syspath_prepend (str (E2B_SCRIPT_DIR ))
You can’t perform that action at this time.
0 commit comments