Skip to content

Commit

Permalink
Add some more skips for if tests are run in an environment that has p…
Browse files Browse the repository at this point in the history
…ython run as root
  • Loading branch information
csm10495 authored and gaborbernat committed Apr 6, 2023
1 parent b29fbb8 commit a2ccce3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def tmp_path_ro(tmp_path: Path) -> Iterator[Path]:

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


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

0 comments on commit a2ccce3

Please sign in to comment.