Skip to content

Commit

Permalink
Better explain the Windows and Unix cases
Browse files Browse the repository at this point in the history
Of PermissionError, in the rmtree tests.
  • Loading branch information
EliahKagan committed Nov 3, 2023
1 parent 1aecb3d commit 143770c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ def permission_error_tmpdir(tmp_path):
td = tmp_path / "testdir"
td.mkdir()
(td / "x").write_bytes(b"")
(td / "x").chmod(stat.S_IRUSR) # Set up PermissionError on Windows.
td.chmod(stat.S_IRUSR | stat.S_IXUSR) # Set up PermissionError on Unix.

# Set up PermissionError on Windows, where we can't delete read-only files.
(td / "x").chmod(stat.S_IRUSR)

# Set up PermissionError on Unix, where we can't delete files in read-only directories.
td.chmod(stat.S_IRUSR | stat.S_IXUSR)

yield td


Expand Down Expand Up @@ -113,7 +118,7 @@ def test_wraps_perm_error_if_enabled(self, mocker, permission_error_tmpdir):
# git.index.util "replaces" git.util and is what "import git.util" gives us.
mocker.patch.object(sys.modules["git.util"], "HIDE_WINDOWS_KNOWN_ERRORS", True)

# Disable common chmod functions so the callback can't fix the problem.
# Disable common chmod functions so the callback can never fix the problem.
mocker.patch.object(os, "chmod")
mocker.patch.object(pathlib.Path, "chmod")

Expand Down

0 comments on commit 143770c

Please sign in to comment.