Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document some minor subtleties in test_util.py #1749

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ 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 common 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")
mocker.patch.object(pathlib.Path, "chmod")

Expand Down Expand Up @@ -256,14 +258,15 @@ def _xfail_param(*values, **xfail_kwargs):
(R"D:/Apps\fOO", "/cygdrive/d/Apps/fOO"),
(R"D:\Apps/123", "/cygdrive/d/Apps/123"),
)
"""Path test cases for cygpath and decygpath, other than extended UNC paths."""

_unc_cygpath_pairs = (
(R"\\?\a:\com", "/cygdrive/a/com"),
(R"\\?\a:/com", "/cygdrive/a/com"),
(R"\\?\UNC\server\D$\Apps", "//server/D$/Apps"),
)
"""Extended UNC path test cases for cygpath."""

# Mapping of expected failures for the test_cygpath_ok test.
_cygpath_ok_xfails = {
# From _norm_cygpath_pairs:
(R"C:\Users", "/cygdrive/c/Users"): "/proc/cygdrive/c/Users",
Expand All @@ -277,9 +280,9 @@ def _xfail_param(*values, **xfail_kwargs):
(R"\\?\a:\com", "/cygdrive/a/com"): "/proc/cygdrive/a/com",
(R"\\?\a:/com", "/cygdrive/a/com"): "/proc/cygdrive/a/com",
}
"""Mapping of expected failures for the test_cygpath_ok test."""


# Parameter sets for the test_cygpath_ok test.
_cygpath_ok_params = [
(
_xfail_param(*case, reason=f"Returns: {_cygpath_ok_xfails[case]!r}", raises=AssertionError)
Expand All @@ -288,6 +291,7 @@ def _xfail_param(*values, **xfail_kwargs):
)
for case in _norm_cygpath_pairs + _unc_cygpath_pairs
]
"""Parameter sets for the test_cygpath_ok test."""


@pytest.mark.skipif(sys.platform != "cygwin", reason="Paths specifically for Cygwin.")
Expand Down
Loading