Skip to content

Your lightweight open-source personal agent.

test(shell): use native paths in sandbox platform fixture

Xubin Ren3a8dc8225134
diff --git a/tests/tools/test_exec_platform.py b/tests/tools/test_exec_platform.py
index 496c1e2e6..d8472288a 100644
--- a/tests/tools/test_exec_platform.py
+++ b/tests/tools/test_exec_platform.py
@@ -524,12 +524,13 @@ class TestSandboxPlatform:
@pytest.mark.asyncio
@pytest.mark.parametrize("backend", ["bwrap", "seatbelt"])
- async def test_sandbox_applied_on_unix(self, backend):
+ async def test_sandbox_applied_on_unix(self, tmp_path, backend):
mock_proc = _CompletedProcess(b"sandboxed")
+ trusted_bin = tmp_path / "trusted-bin"
with (
patch("nanobot.agent.tools.shell._IS_WINDOWS", False),
- patch("nanobot.agent.tools.shell.shutil.which", side_effect=lambda name, **_kwargs: f"/usr/bin/{name}"),
+ patch("nanobot.agent.tools.shell.shutil.which", side_effect=lambda name, **_kwargs: str(trusted_bin / name)),
patch("nanobot.agent.tools.shell.wrap_command", return_value=f"{backend} -- sh -c ls") as mock_wrap,
patch.object(ExecTool, "_spawn", return_value=mock_proc) as mock_spawn,
patch.object(ExecTool, "_guard_command", return_value=None),
@@ -540,7 +541,7 @@ class TestSandboxPlatform:
mock_wrap.assert_called_once()
spawned_cmd = mock_spawn.call_args[0][0]
assert isinstance(spawned_cmd, list)
- assert spawned_cmd[0] == f"/usr/bin/{backend}"
+ assert spawned_cmd[0] == str(trusted_bin / backend)
@pytest.mark.asyncio
@pytest.mark.parametrize("backend", ["bwrap", "seatbelt"])