From fbd90d74b3eaeef2f182af6a494ffe61894fa36d Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Fri, 29 May 2026 22:43:52 -0700 Subject: [PATCH] fix(hooks): Windows-safe subagent_gate tests via tmp_path --- src/aipass/hooks/tests/test_subagent_gate.py | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/aipass/hooks/tests/test_subagent_gate.py b/src/aipass/hooks/tests/test_subagent_gate.py index 8c97358e..82563d8e 100644 --- a/src/aipass/hooks/tests/test_subagent_gate.py +++ b/src/aipass/hooks/tests/test_subagent_gate.py @@ -130,22 +130,24 @@ class TestSubagentGateHandler: class TestSubagentGateExternalProject: """Verify subagent gate works for non-AIPass projects (e.g. src/vera_studio/).""" - def test_get_cwd_branch_external_package(self): - from pathlib import Path + def test_get_cwd_branch_external_package(self, tmp_path): from aipass.hooks.apps.handlers.security.subagent_gate import _get_cwd_branch - repo_root = Path("/home/user/Projects/vera") - cwd = "/home/user/Projects/vera/src/vera_studio/quality" - branch = _get_cwd_branch(cwd, repo_root) + # Use tmp_path for OS-native, drive-anchored paths — synthetic POSIX + # strings break on Windows where .resolve() anchors to the current drive. + repo_root = tmp_path / "vera" + cwd = repo_root / "src" / "vera_studio" / "quality" + cwd.mkdir(parents=True) + branch = _get_cwd_branch(str(cwd), repo_root) assert branch == "quality" - def test_get_cwd_branch_aipass_still_works(self): - from pathlib import Path + def test_get_cwd_branch_aipass_still_works(self, tmp_path): from aipass.hooks.apps.handlers.security.subagent_gate import _get_cwd_branch - repo_root = Path("/home/user/Projects/AIPass") - cwd = "/home/user/Projects/AIPass/src/aipass/hooks" - branch = _get_cwd_branch(cwd, repo_root) + repo_root = tmp_path / "AIPass" + cwd = repo_root / "src" / "aipass" / "hooks" + cwd.mkdir(parents=True) + branch = _get_cwd_branch(str(cwd), repo_root) assert branch == "hooks" def test_get_package_from_cwd_external(self):