Skip to content
Prev Previous commit
Next Next commit
Start making TestCygpath xfail markings granular
This marks only the one really expected failure case in
in test_cygpath_norm_ok as xfail, preventing the others from
giving "XPASS" results each time the tests are run.
  • Loading branch information
EliahKagan committed Nov 3, 2023
commit 487bc8aa71ebfdfa455c4037d0bbcfd51eb4997c
11 changes: 6 additions & 5 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ def test_env_vars_for_windows_tests(self, name, env_var_value, expected_truth_va
assert actual_parsed_value is expected_truth_value


def _xfail_param(*values, **xfail_kwargs):
"""Build a pytest.mark.parametrize parameter that carries an xfail mark."""
return pytest.param(*values, marks=pytest.mark.xfail(**xfail_kwargs))


@pytest.mark.skipif(sys.platform != "cygwin", reason="Paths specifically for Cygwin.")
class TestCygpath:
"""Tests for :func:`git.util.cygpath` and :func:`git.util.decygpath`."""
Expand Down Expand Up @@ -246,15 +251,11 @@ def test_cygpath_ok(self, wpath, cpath):
cwpath = cygpath(wpath)
assert cwpath == cpath, wpath

@pytest.mark.xfail(
reason=R'2nd example r".\bar" -> "bar" fails, returns "./bar"',
raises=AssertionError,
)
@pytest.mark.parametrize(
"wpath, cpath",
[
(R"./bar", "bar"),
(R".\bar", "bar"), # FIXME: Mark only this one xfail (or fix it).
_xfail_param(R".\bar", "bar", reason=R'Returns: "./bar"', raises=AssertionError),
(R"../bar", "../bar"),
(R"..\bar", "../bar"),
(R"../bar/.\foo/../chu", "../bar/chu"),
Expand Down