test(agent): use python3 in ExecTool workspace scope tests (#5064)

* test(agent): use python3 in ExecTool workspace scope tests (fixes #5062)

* test(agent): use python on Windows and python3 on POSIX in ExecTool workspace scope tests (fixes #5062)

* test(agent): share Python command fixture

---------

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
flyzstu
2026-07-24 09:42:38 +08:00
committed by GitHub
co-authored by chengyongru
parent aae259c790
commit 8bcab8885e
2 changed files with 17 additions and 4 deletions
+7
View File
@@ -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",
*,
+10 -4
View File
@@ -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),