1 file changed
@@ -49,8 +49,13 @@ def permission_error_tmpdir(tmp_path): | |||
| 49 | 49 | td = tmp_path / "testdir" | |
| 50 | 50 | td.mkdir() | |
| 51 | 51 | (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 | + | ||
| 54 | 59 | yield td | |
| 55 | 60 | ||
| 56 | 61 | ||
@@ -113,7 +118,7 @@ def test_wraps_perm_error_if_enabled(self, mocker, permission_error_tmpdir): | |||
| 113 | 118 | # git.index.util "replaces" git.util and is what "import git.util" gives us. | |
| 114 | 119 | mocker.patch.object(sys.modules["git.util"], "HIDE_WINDOWS_KNOWN_ERRORS", True) | |
| 115 | 120 | ||
| 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. | ||
| 117 | 122 | mocker.patch.object(os, "chmod") | |
| 118 | 123 | mocker.patch.object(pathlib.Path, "chmod") | |
| 119 | 124 | ||
0 commit comments