From 603d24566d04fbd37b694153c0f65aa4233cbbc0 Mon Sep 17 00:00:00 2001 From: Cowork Supervisor Date: Wed, 12 Aug 2026 03:14:16 -0400 Subject: [PATCH] test(#93): key injected mode/chmod maps on as_posix() for the Windows runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit permission_status/fix_permissions wrap paths in the running OS's Path class, so on the windows-latest CI job str(p) uses backslashes and the fixture dict lookups miss — the same portability trap fixed for #91. Normalise with Path(p).as_posix() in the four affected lambdas. Pure test fix; production code unchanged. Co-Authored-By: Claude Opus 4.8 --- tests/test_core.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index f84a6f4..49184d6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3428,10 +3428,13 @@ def test_sidecar_status_none_for_unknown_package(): # Filesystem permission pre-flight (issue #93) # --------------------------------------------------------------------------- # def test_permission_status_ok_when_0600(): + # NOTE: key the injected mode map on Path(p).as_posix() — on the Windows CI + # runner permission_status wraps the path in a WindowsPath, so str(p) would + # use backslashes and miss the lookup (the same portability trap as #91). st = c.permission_status( "/cfg/config.toml", platform="darwin", - stat_mode=lambda p: {"/cfg/config.toml": 0o600, "/cfg": 0o700}.get(str(p)), + stat_mode=lambda p: {"/cfg/config.toml": 0o600, "/cfg": 0o700}.get(Path(p).as_posix()), ) assert st["ok"] is True assert st["mode"] == 0o600 @@ -3442,7 +3445,7 @@ def test_permission_status_blocks_group_world_readable_file(): st = c.permission_status( "/cfg/config.toml", platform="linux", - stat_mode=lambda p: {"/cfg/config.toml": 0o644, "/cfg": 0o755}.get(str(p)), + stat_mode=lambda p: {"/cfg/config.toml": 0o644, "/cfg": 0o755}.get(Path(p).as_posix()), ) assert st["ok"] is False assert st["file_ok"] is False @@ -3457,7 +3460,7 @@ def test_permission_status_file_bad_dir_ok(): st = c.permission_status( "/cfg/config.toml", platform="linux", - stat_mode=lambda p: {"/cfg/config.toml": 0o640, "/cfg": 0o700}.get(str(p)), + stat_mode=lambda p: {"/cfg/config.toml": 0o640, "/cfg": 0o700}.get(Path(p).as_posix()), ) assert st["file_ok"] is False assert st["dir_ok"] is True @@ -3472,9 +3475,12 @@ def test_permission_status_none_on_windows_and_missing_file(): def test_fix_permissions_chmods_file_and_dir(): + # as_posix() so the recorded paths compare equal on the Windows CI runner too. calls = [] changed, note = c.fix_permissions( - "/cfg/config.toml", platform="linux", chmod=lambda p, m: calls.append((str(p), m)) + "/cfg/config.toml", + platform="linux", + chmod=lambda p, m: calls.append((Path(p).as_posix(), m)), ) assert changed is True assert ("/cfg/config.toml", 0o600) in calls