test(#93): key injected mode/chmod maps on as_posix() for the Windows runner
CI / Lint (ruff) (pull_request) Successful in 9s
CI / Tests (py3.12 / windows-latest) (pull_request) Successful in 23s
CI / Tests (py3.10 / ubuntu-latest) (pull_request) Successful in 12s
CI / Tests (py3.12 / ubuntu-latest) (pull_request) Successful in 16s
CI / Tests (py3.13 / ubuntu-latest) (pull_request) Successful in 13s
CI / Catalog signature (pull_request) Successful in 8s
CI / Lint (ruff) (pull_request) Successful in 9s
CI / Tests (py3.12 / windows-latest) (pull_request) Successful in 23s
CI / Tests (py3.10 / ubuntu-latest) (pull_request) Successful in 12s
CI / Tests (py3.12 / ubuntu-latest) (pull_request) Successful in 16s
CI / Tests (py3.13 / ubuntu-latest) (pull_request) Successful in 13s
CI / Catalog signature (pull_request) Successful in 8s
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0b2827e6b8
commit
603d24566d
+10
-4
@@ -3428,10 +3428,13 @@ def test_sidecar_status_none_for_unknown_package():
|
|||||||
# Filesystem permission pre-flight (issue #93)
|
# Filesystem permission pre-flight (issue #93)
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
def test_permission_status_ok_when_0600():
|
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(
|
st = c.permission_status(
|
||||||
"/cfg/config.toml",
|
"/cfg/config.toml",
|
||||||
platform="darwin",
|
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["ok"] is True
|
||||||
assert st["mode"] == 0o600
|
assert st["mode"] == 0o600
|
||||||
@@ -3442,7 +3445,7 @@ def test_permission_status_blocks_group_world_readable_file():
|
|||||||
st = c.permission_status(
|
st = c.permission_status(
|
||||||
"/cfg/config.toml",
|
"/cfg/config.toml",
|
||||||
platform="linux",
|
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["ok"] is False
|
||||||
assert st["file_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(
|
st = c.permission_status(
|
||||||
"/cfg/config.toml",
|
"/cfg/config.toml",
|
||||||
platform="linux",
|
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["file_ok"] is False
|
||||||
assert st["dir_ok"] is True
|
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():
|
def test_fix_permissions_chmods_file_and_dir():
|
||||||
|
# as_posix() so the recorded paths compare equal on the Windows CI runner too.
|
||||||
calls = []
|
calls = []
|
||||||
changed, note = c.fix_permissions(
|
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 changed is True
|
||||||
assert ("/cfg/config.toml", 0o600) in calls
|
assert ("/cfg/config.toml", 0o600) in calls
|
||||||
|
|||||||
Reference in New Issue
Block a user