Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite309b35

Browse files
committed
Mock out lchmod functions in _patch_for_wrapping_test?
TestRmtree._patch_for_wrapping_test already mocked out the regularchmod functions in the os module and the Path class, to test whathappens when changing permissions cannot fix an error. But thereare also, on some systems and Python versions, lchmod versions ofthese functions. This patches those as well.I am not sure this should really be done. The problem is thatcalling such functions is fairly likely to raise an exception ifit is not properly conditioned on a check for their actualusability, and mocking them out could obscure such a bug.
1 parent5c6a4f4 commite309b35

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎test/test_util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,15 @@ def _patch_for_wrapping_test(self, mocker, hide_windows_known_errors):
140140
# git.index.util "replaces" git.util and is what "import git.util" gives us.
141141
mocker.patch.object(sys.modules["git.util"],"HIDE_WINDOWS_KNOWN_ERRORS",hide_windows_known_errors)
142142

143-
# Disablecommon chmod functions so the callback can't fix a PermissionError.
143+
# Disablesome chmod functions so the callback can't fix a PermissionError.
144144
mocker.patch.object(os,"chmod")
145+
ifhasattr(os,"lchmod"):
146+
# Exists on some operating systems. Mocking out os.chmod doesn't affect it.
147+
mocker.patch.object(os,"lchmod")
145148
mocker.patch.object(pathlib.Path,"chmod")
149+
ifhasattr(pathlib.Path,"lchmod"):
150+
# Exists on some Python versions. Don't rely on it calling a public chmod.
151+
mocker.patch.object(pathlib.Path,"lchmod")
146152

147153
@pytest.mark.skipif(
148154
os.name!="nt",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp