diff --git a/tests/agent/conftest.py b/tests/agent/conftest.py index c239733b..9bb4b65b 100644 --- a/tests/agent/conftest.py +++ b/tests/agent/conftest.py @@ -2,6 +2,7 @@ from __future__ import annotations +import os from pathlib import Path from types import SimpleNamespace from unittest.mock import AsyncMock, MagicMock, patch @@ -13,6 +14,12 @@ from nanobot.bus.queue import MessageBus from nanobot.providers.base import LLMProvider +@pytest.fixture +def cmd_python() -> str: + """Return the Python command name available to ExecTool tests.""" + return "python" if os.name == "nt" else "python3" + + def make_provider( default_model: str = "test-model", *, diff --git a/tests/agent/test_workspace_scope.py b/tests/agent/test_workspace_scope.py index 2c5aefa9..8ca76696 100644 --- a/tests/agent/test_workspace_scope.py +++ b/tests/agent/test_workspace_scope.py @@ -257,7 +257,10 @@ async def test_filesystem_write_tool_full_scope_allows_outside_project(tmp_path: @pytest.mark.asyncio -async def test_exec_tool_uses_scope_project_as_default_cwd(tmp_path: Path) -> None: +async def test_exec_tool_uses_scope_project_as_default_cwd( + tmp_path: Path, + cmd_python: str, +) -> None: project = tmp_path / "project" project.mkdir() tool = ExecTool(working_dir=str(tmp_path), restrict_to_workspace=False, timeout=5) @@ -270,7 +273,7 @@ async def test_exec_tool_uses_scope_project_as_default_cwd(tmp_path: Path) -> No try: result = await tool.execute( command=( - 'python -c "from pathlib import Path; ' + f'{cmd_python} -c "from pathlib import Path; ' "Path('scoped-marker.txt').write_text('ok')\"" ) ) @@ -282,7 +285,10 @@ async def test_exec_tool_uses_scope_project_as_default_cwd(tmp_path: Path) -> No @pytest.mark.asyncio -async def test_exec_full_scope_allows_explicit_cwd_outside_project(tmp_path: Path) -> None: +async def test_exec_full_scope_allows_explicit_cwd_outside_project( + tmp_path: Path, + cmd_python: str, +) -> None: project = tmp_path / "project" outside = tmp_path / "outside" project.mkdir() @@ -297,7 +303,7 @@ async def test_exec_full_scope_allows_explicit_cwd_outside_project(tmp_path: Pat try: result = await tool.execute( command=( - 'python -c "from pathlib import Path; ' + f'{cmd_python} -c "from pathlib import Path; ' "Path('outside-marker.txt').write_text('ok')\"" ), working_dir=str(outside),