Catch MontyRuntimeError from Monty() constructor
This commit is contained in:
parent
380fc6c930
commit
1ee9747551
2 changed files with 11 additions and 1 deletions
|
|
@ -162,7 +162,10 @@ class Sandbox:
|
||||||
inputs=input_names,
|
inputs=input_names,
|
||||||
external_functions=list(external_fns.keys()),
|
external_functions=list(external_fns.keys()),
|
||||||
)
|
)
|
||||||
except pydantic_monty.MontySyntaxError as e:
|
except (
|
||||||
|
pydantic_monty.MontySyntaxError,
|
||||||
|
pydantic_monty.MontyRuntimeError,
|
||||||
|
) as e:
|
||||||
return SandboxResult(stdout="", stderr=str(e), success=False)
|
return SandboxResult(stdout="", stderr=str(e), success=False)
|
||||||
|
|
||||||
stdout_lines: list[str] = []
|
stdout_lines: list[str] = []
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,13 @@ class TestSandboxErrors:
|
||||||
assert not result.success
|
assert not result.success
|
||||||
assert "NameError" in result.stderr
|
assert "NameError" in result.stderr
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_multi_module_import(self, sandbox):
|
||||||
|
"""Test that unsupported multi-module imports are caught gracefully."""
|
||||||
|
result = await sandbox.execute("import json, string")
|
||||||
|
assert not result.success
|
||||||
|
assert result.stderr != ""
|
||||||
|
|
||||||
|
|
||||||
class TestSandboxHaikuRAG:
|
class TestSandboxHaikuRAG:
|
||||||
"""Test haiku.rag functions in sandbox."""
|
"""Test haiku.rag functions in sandbox."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue