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

Commit1dccb8e

Browse files
committed
Pull cygpath and decygpath tests out of TestUtils
This turns them into pure pytest tests, in a new class TestCygpath.
1 parent2fb8c64 commit1dccb8e

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

‎test/test_util.py

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
importsys
1515
importtempfile
1616
importtime
17-
fromunittestimportSkipTest,mock,skipUnless
17+
fromunittestimportSkipTest,mock
1818

1919
importddt
2020
importpytest
@@ -45,7 +45,7 @@
4545

4646
@pytest.fixture
4747
defpermission_error_tmpdir(tmp_path):
48-
"""Fixture to test permissions errors situations where they are not overcome."""
48+
"""Fixture to test permissions errorsinsituations where they are not overcome."""
4949
td=tmp_path/"testdir"
5050
td.mkdir()
5151
(td/"x").write_bytes(b"")
@@ -211,21 +211,9 @@ def test_env_vars_for_windows_tests(self, name, env_var_value, expected_truth_va
211211
assertactual_parsed_valueisexpected_truth_value
212212

213213

214-
class_Member:
215-
"""A member of an IterableList."""
216-
217-
__slots__= ("name",)
218-
219-
def__init__(self,name):
220-
self.name=name
221-
222-
def__repr__(self):
223-
returnf"{type(self).__name__}({self.name!r})"
224-
225-
226-
@ddt.ddt
227-
classTestUtils(TestBase):
228-
"""Tests for most utilities in :mod:`git.util`."""
214+
@pytest.mark.skipif(sys.platform!="cygwin",reason="Paths specifically for Cygwin.")
215+
classTestCygpath:
216+
"""Tests for :func:`git.util.cygpath` and :func:`git.util.decygpath`."""
229217

230218
_norm_cygpath_pairs= (
231219
(R"foo\bar","foo/bar"),
@@ -248,54 +236,70 @@ class TestUtils(TestBase):
248236
(R"\\?\UNC\server\D$\Apps","//server/D$/Apps"),
249237
)
250238

251-
# FIXME: Mark only the /proc-prefixing cases xfail, somehow (or fix them).
239+
# FIXME: Mark only the /proc-prefixing cases xfail (or fix them).
252240
@pytest.mark.xfail(
253241
reason="Many return paths prefixed /proc/cygdrive instead.",
254242
raises=AssertionError,
255243
)
256-
@skipUnless(sys.platform=="cygwin","Paths specifically for Cygwin.")
257-
@ddt.idata(_norm_cygpath_pairs+_unc_cygpath_pairs)
258-
deftest_cygpath_ok(self,case):
259-
wpath,cpath=case
244+
@pytest.mark.parametrize("wpath, cpath",_norm_cygpath_pairs+_unc_cygpath_pairs)
245+
deftest_cygpath_ok(self,wpath,cpath):
260246
cwpath=cygpath(wpath)
261-
self.assertEqual(cwpath,cpath,wpath)
247+
assertcwpath==cpath,wpath
262248

263249
@pytest.mark.xfail(
264250
reason=R'2nd example r".\bar" -> "bar" fails, returns "./bar"',
265251
raises=AssertionError,
266252
)
267-
@skipUnless(sys.platform=="cygwin","Paths specifically for Cygwin.")
268-
@ddt.data(
269-
(R"./bar","bar"),
270-
(R".\bar","bar"),# FIXME: Mark only this one xfail, somehow (or fix it).
271-
(R"../bar","../bar"),
272-
(R"..\bar","../bar"),
273-
(R"../bar/.\foo/../chu","../bar/chu"),
253+
@pytest.mark.parametrize(
254+
"wpath, cpath",
255+
[
256+
(R"./bar","bar"),
257+
(R".\bar","bar"),# FIXME: Mark only this one xfail (or fix it).
258+
(R"../bar","../bar"),
259+
(R"..\bar","../bar"),
260+
(R"../bar/.\foo/../chu","../bar/chu"),
261+
],
274262
)
275-
deftest_cygpath_norm_ok(self,case):
276-
wpath,cpath=case
263+
deftest_cygpath_norm_ok(self,wpath,cpath):
277264
cwpath=cygpath(wpath)
278-
self.assertEqual(cwpath,cpathorwpath,wpath)
265+
assertcwpath== (cpathorwpath),wpath
279266

280-
@skipUnless(sys.platform=="cygwin","Paths specifically for Cygwin.")
281-
@ddt.data(
282-
R"C:",
283-
R"C:Relative",
284-
R"D:Apps\123",
285-
R"D:Apps/123",
286-
R"\\?\a:rel",
287-
R"\\share\a:rel",
267+
@pytest.mark.parametrize(
268+
"wpath",
269+
[
270+
R"C:",
271+
R"C:Relative",
272+
R"D:Apps\123",
273+
R"D:Apps/123",
274+
R"\\?\a:rel",
275+
R"\\share\a:rel",
276+
],
288277
)
289278
deftest_cygpath_invalids(self,wpath):
290279
cwpath=cygpath(wpath)
291-
self.assertEqual(cwpath,wpath.replace("\\","/"),wpath)
280+
assertcwpath==wpath.replace("\\","/"),wpath
292281

293-
@skipUnless(sys.platform=="cygwin","Paths specifically for Cygwin.")
294-
@ddt.idata(_norm_cygpath_pairs)
295-
deftest_decygpath(self,case):
296-
wpath,cpath=case
282+
@pytest.mark.parametrize("wpath, cpath",_norm_cygpath_pairs)
283+
deftest_decygpath(self,wpath,cpath):
297284
wcpath=decygpath(cpath)
298-
self.assertEqual(wcpath,wpath.replace("/","\\"),cpath)
285+
assertwcpath==wpath.replace("/","\\"),cpath
286+
287+
288+
class_Member:
289+
"""A member of an IterableList."""
290+
291+
__slots__= ("name",)
292+
293+
def__init__(self,name):
294+
self.name=name
295+
296+
def__repr__(self):
297+
returnf"{type(self).__name__}({self.name!r})"
298+
299+
300+
@ddt.ddt
301+
classTestUtils(TestBase):
302+
"""Tests for most utilities in :mod:`git.util`."""
299303

300304
deftest_it_should_dashify(self):
301305
self.assertEqual("this-is-my-argument",dashify("this_is_my_argument"))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp