diff --git a/tests/code_utils/test_config_js.py b/tests/code_utils/test_config_js.py index a533b8124..d2a116562 100644 --- a/tests/code_utils/test_config_js.py +++ b/tests/code_utils/test_config_js.py @@ -3,6 +3,7 @@ from __future__ import annotations import json +import os import sys from pathlib import Path @@ -73,7 +74,10 @@ def test_returns_none_for_nonexistent_file(self, tmp_path: Path) -> None: assert result is None - @pytest.mark.skipif(sys.platform == "win32", reason="chmod doesn't restrict read access on Windows") + @pytest.mark.skipif( + sys.platform == "win32" or os.getuid() == 0, + reason="chmod doesn't restrict read access on Windows or when running as root" + ) def test_returns_none_for_unreadable_file(self, tmp_path: Path) -> None: """Should return None if file cannot be read.""" package_json = tmp_path / "package.json"