Skip to content

Commit c3d3d1e

Browse files
committed
Finish making TestCygpath xfail markings granular
This marks only the (many, but not all) really expected failure cases in test_cygpath_ok as xfail, preventing the others from giving "XPASS" results each time the tests are run. This finishes making the xfail markings in TestCygpath granular, in the sense that now there should be no "XPASS" results. However, the approach taken here might still benefit from future reorganization or refactoring.
1 parent 487bc8a commit c3d3d1e

File tree

1 file changed

+50
-28
lines changed

1 file changed

+50
-28
lines changed

Diff for: test/test_util.py

+50-28
Original file line numberDiff line numberDiff line change
@@ -216,37 +216,59 @@ def _xfail_param(*values, **xfail_kwargs):
216216
return pytest.param(*values, marks=pytest.mark.xfail(**xfail_kwargs))
217217

218218

219-
@pytest.mark.skipif(sys.platform != "cygwin", reason="Paths specifically for Cygwin.")
220-
class TestCygpath:
221-
"""Tests for :func:`git.util.cygpath` and :func:`git.util.decygpath`."""
219+
_norm_cygpath_pairs = (
220+
(R"foo\bar", "foo/bar"),
221+
(R"foo/bar", "foo/bar"),
222+
(R"C:\Users", "/cygdrive/c/Users"),
223+
(R"C:\d/e", "/cygdrive/c/d/e"),
224+
("C:\\", "/cygdrive/c/"),
225+
(R"\\server\C$\Users", "//server/C$/Users"),
226+
(R"\\server\C$", "//server/C$"),
227+
("\\\\server\\c$\\", "//server/c$/"),
228+
(R"\\server\BAR/", "//server/BAR/"),
229+
(R"D:/Apps", "/cygdrive/d/Apps"),
230+
(R"D:/Apps\fOO", "/cygdrive/d/Apps/fOO"),
231+
(R"D:\Apps/123", "/cygdrive/d/Apps/123"),
232+
)
222233

223-
_norm_cygpath_pairs = (
224-
(R"foo\bar", "foo/bar"),
225-
(R"foo/bar", "foo/bar"),
226-
(R"C:\Users", "/cygdrive/c/Users"),
227-
(R"C:\d/e", "/cygdrive/c/d/e"),
228-
("C:\\", "/cygdrive/c/"),
229-
(R"\\server\C$\Users", "//server/C$/Users"),
230-
(R"\\server\C$", "//server/C$"),
231-
("\\\\server\\c$\\", "//server/c$/"),
232-
(R"\\server\BAR/", "//server/BAR/"),
233-
(R"D:/Apps", "/cygdrive/d/Apps"),
234-
(R"D:/Apps\fOO", "/cygdrive/d/Apps/fOO"),
235-
(R"D:\Apps/123", "/cygdrive/d/Apps/123"),
236-
)
234+
_unc_cygpath_pairs = (
235+
(R"\\?\a:\com", "/cygdrive/a/com"),
236+
(R"\\?\a:/com", "/cygdrive/a/com"),
237+
(R"\\?\UNC\server\D$\Apps", "//server/D$/Apps"),
238+
)
237239

238-
_unc_cygpath_pairs = (
239-
(R"\\?\a:\com", "/cygdrive/a/com"),
240-
(R"\\?\a:/com", "/cygdrive/a/com"),
241-
(R"\\?\UNC\server\D$\Apps", "//server/D$/Apps"),
240+
# Mapping of expected failures for the test_cygpath_ok test.
241+
_cygpath_ok_xfails = {
242+
# From _norm_cygpath_pairs:
243+
(R"C:\Users", "/cygdrive/c/Users"): "/proc/cygdrive/c/Users",
244+
(R"C:\d/e", "/cygdrive/c/d/e"): "/proc/cygdrive/c/d/e",
245+
("C:\\", "/cygdrive/c/"): "/proc/cygdrive/c/",
246+
(R"\\server\BAR/", "//server/BAR/"): "//server/BAR",
247+
(R"D:/Apps", "/cygdrive/d/Apps"): "/proc/cygdrive/d/Apps",
248+
(R"D:/Apps\fOO", "/cygdrive/d/Apps/fOO"): "/proc/cygdrive/d/Apps/fOO",
249+
(R"D:\Apps/123", "/cygdrive/d/Apps/123"): "/proc/cygdrive/d/Apps/123",
250+
# From _unc_cygpath_pairs:
251+
(R"\\?\a:\com", "/cygdrive/a/com"): "/proc/cygdrive/a/com",
252+
(R"\\?\a:/com", "/cygdrive/a/com"): "/proc/cygdrive/a/com",
253+
}
254+
255+
256+
# Parameter sets for the test_cygpath_ok test.
257+
_cygpath_ok_params = [
258+
(
259+
_xfail_param(*case, reason=f"Returns: {_cygpath_ok_xfails[case]!r}", raises=AssertionError)
260+
if case in _cygpath_ok_xfails
261+
else case
242262
)
263+
for case in _norm_cygpath_pairs + _unc_cygpath_pairs
264+
]
243265

244-
# FIXME: Mark only the /proc-prefixing cases xfail (or fix them).
245-
@pytest.mark.xfail(
246-
reason="Many return paths prefixed /proc/cygdrive instead.",
247-
raises=AssertionError,
248-
)
249-
@pytest.mark.parametrize("wpath, cpath", _norm_cygpath_pairs + _unc_cygpath_pairs)
266+
267+
@pytest.mark.skipif(sys.platform != "cygwin", reason="Paths specifically for Cygwin.")
268+
class TestCygpath:
269+
"""Tests for :func:`git.util.cygpath` and :func:`git.util.decygpath`."""
270+
271+
@pytest.mark.parametrize("wpath, cpath", _cygpath_ok_params)
250272
def test_cygpath_ok(self, wpath, cpath):
251273
cwpath = cygpath(wpath)
252274
assert cwpath == cpath, wpath
@@ -255,7 +277,7 @@ def test_cygpath_ok(self, wpath, cpath):
255277
"wpath, cpath",
256278
[
257279
(R"./bar", "bar"),
258-
_xfail_param(R".\bar", "bar", reason=R'Returns: "./bar"', raises=AssertionError),
280+
_xfail_param(R".\bar", "bar", reason="Returns: './bar'", raises=AssertionError),
259281
(R"../bar", "../bar"),
260282
(R"..\bar", "../bar"),
261283
(R"../bar/.\foo/../chu", "../bar/chu"),

0 commit comments

Comments
 (0)