Skip to content

Commit a2ccce3

Browse files
csm10495gaborbernat
authored andcommitted
Add some more skips for if tests are run in an environment that has python run as root
1 parent b29fbb8 commit a2ccce3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_filelock.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def tmp_path_ro(tmp_path: Path) -> Iterator[Path]:
8383

8484
@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
8585
@pytest.mark.skipif(sys.platform == "win32", reason="Windows does not have read only folders")
86+
@pytest.mark.skipif(
87+
sys.platform != "win32" and os.geteuid() == 0, # noqa: SC200
88+
reason="Cannot make a read only file (that the current user: root can't read)",
89+
)
8690
def test_ro_folder(lock_type: type[BaseFileLock], tmp_path_ro: Path) -> None:
8791
lock = lock_type(str(tmp_path_ro / "a"))
8892
with pytest.raises(PermissionError, match="Permission denied"):
@@ -98,6 +102,10 @@ def tmp_file_ro(tmp_path: Path) -> Iterator[Path]:
98102

99103

100104
@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
105+
@pytest.mark.skipif(
106+
sys.platform != "win32" and os.geteuid() == 0, # noqa: SC200
107+
reason="Cannot make a read only file (that the current user: root can't read)",
108+
)
101109
def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None:
102110
lock = lock_type(str(tmp_file_ro))
103111
with pytest.raises(PermissionError, match="Permission denied"):

0 commit comments

Comments
 (0)