test: guard os.geteuid() for Windows in the ACP launcher tests

os.geteuid() does not exist on Windows, so collecting the module
crashed with AttributeError before any test ran. Branch on
hasattr(os, "geteuid") the same way the code under test does.
This commit is contained in:
emozilla
2026-08-22 13:39:04 -04:00
parent 5d5179d7a9
commit 0605279b35

View File

@@ -52,6 +52,13 @@ def test_does_not_follow_symlink_into_venv(fake_home, tmp_path):
def test_unwritable_bin_dir_is_skipped(fake_home):
(fake_home / "hermes").write_text("#!/bin/sh\n", encoding="utf-8")
if not hasattr(os, "geteuid"):
# Windows: no geteuid, and chmod can't make a directory unwritable
# anyway. _ensure_acp_launcher is an explicit no-op there, so the
# assertion below still holds — vacuously.
_ensure_acp_launcher()
assert not (fake_home / "hermes-acp").exists()
return
if os.geteuid() == 0:
pytest.skip("root ignores directory write permissions")
fake_home.chmod(0o555)