Skip to content

Commit ba5bc45

Browse files
committed
Better explain the Windows and Unix cases
Of PermissionError, in the rmtree tests.
1 parent 7d98f94 commit ba5bc45

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: test/test_util.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ def permission_error_tmpdir(tmp_path):
4949
td = tmp_path / "testdir"
5050
td.mkdir()
5151
(td / "x").write_bytes(b"")
52-
(td / "x").chmod(stat.S_IRUSR) # Set up PermissionError on Windows.
53-
td.chmod(stat.S_IRUSR | stat.S_IXUSR) # Set up PermissionError on Unix.
52+
53+
# Set up PermissionError on Windows, where we can't delete read-only files.
54+
(td / "x").chmod(stat.S_IRUSR)
55+
56+
# Set up PermissionError on Unix, where we can't delete files in read-only directories.
57+
td.chmod(stat.S_IRUSR | stat.S_IXUSR)
58+
5459
yield td
5560

5661

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

116-
# Disable common chmod functions so the callback can't fix the problem.
121+
# Disable common chmod functions so the callback can never fix the problem.
117122
mocker.patch.object(os, "chmod")
118123
mocker.patch.object(pathlib.Path, "chmod")
119124

0 commit comments

Comments
 (0)