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

This commit is contained in:
Xubin Ren committed 2026-11-04 23:33:49 +08:00
1 parent 219dd13fd8
commit 3a8dc82251
1 file changed
+4 -3
+4 -3
View File
@@ -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"])