From a09e5383cc9bbba290c18c22d925065453b47747 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Tue, 28 Nov 2023 20:47:38 -0500 Subject: [PATCH] Don't mock the lchmod functions, and explain why This undoes the mocking of lchmod functions from e309b35, and instead notes why they may be better left alone in the tests. This also rewords the existing comment to better explain the reason for the mocking that is being done. --- test/test_util.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/test_util.py b/test/test_util.py index e003fcb05..68f75aa45 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -140,15 +140,11 @@ def _patch_for_wrapping_test(self, mocker, hide_windows_known_errors): # 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", hide_windows_known_errors) - # Disable some chmod functions so the callback can't fix a PermissionError. + # Mock out common chmod functions to simulate PermissionError the callback can't + # fix. (We leave the corresponding lchmod functions alone. If they're used, it's + # more important we detect any failures from inadequate compatibility checks.) mocker.patch.object(os, "chmod") - if hasattr(os, "lchmod"): - # Exists on some operating systems. Mocking out os.chmod doesn't affect it. - mocker.patch.object(os, "lchmod") mocker.patch.object(pathlib.Path, "chmod") - if hasattr(pathlib.Path, "lchmod"): - # Exists on some Python versions. Don't rely on it calling a public chmod. - mocker.patch.object(pathlib.Path, "lchmod") @pytest.mark.skipif( os.name != "nt",