Skip to content

Commit 97fbd28

Browse files
authored
test: make binary detection independent of ambient PATH
Merge reviewed hermetic binary-detection test coverage.
2 parents 7001232 + 34588f9 commit 97fbd28

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/test_skill.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import os
99
from pathlib import Path
10+
import stat
1011
from unittest.mock import patch
1112

1213
import pytest
@@ -84,13 +85,20 @@ def test_returns_none_when_no_version(self, tmp_path: Path) -> None:
8485
class TestIsToolInstalled:
8586
"""Test the two-signal tool detection logic."""
8687

87-
def test_detected_via_binary_on_path(self) -> None:
88+
def test_detected_via_binary_on_path(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
89+
bin_dir = tmp_path / "bin"
90+
bin_dir.mkdir()
91+
binary = bin_dir / "fake-tool.exe"
92+
binary.touch()
93+
binary.chmod(binary.stat().st_mode | stat.S_IXUSR)
94+
monkeypatch.setenv("PATH", str(bin_dir))
95+
8896
target = SkillTarget(
8997
name="fake-tool",
9098
description="T",
9199
user_dir=Path("/nonexistent/skills"),
92100
project_dir=".fake/skills",
93-
binary="python3",
101+
binary=binary.name,
94102
root_dirs=[],
95103
)
96104
assert _is_tool_installed(target) is True

0 commit comments

Comments
 (0)