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

Commitc4da058

Browse files
committed
Pull HIDE_WINDOWS_*_ERRORS tests out of TestUtils
And make them pure pytest tests. This creates the TestEnvParsingclass, which does not inherit from TestCase.Because unlike @ddt.data (and @ddt.idata) @pytest.mark.parametrizecan be nested (applied multiple times, creating tests for allcombinations), that is used for the HIDE_WINDOWS_*_ERRORS testsinstead of subtests. Because there were not any other uses ofsubtests in the test suite, the pytest-subtest plugin isaccordingly removed from test-requirements. It may be put backanytime in the future.
1 parente2fa5e2 commitc4da058

File tree

2 files changed

+48
-35
lines changed

2 files changed

+48
-35
lines changed

‎test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ pytest >= 7.3.1
88
pytest-cov
99
pytest-instafail
1010
pytest-mock
11-
pytest-subtests
1211
pytest-sugar

‎test/test_util.py

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -155,38 +155,26 @@ def test_does_not_wrap_other_errors(self, mocker, file_not_found_tmpdir, hide_wi
155155
self.fail(f"rmtree unexpectedly attempts skip:{ex!r}")
156156

157157

158-
class_Member:
159-
"""A member of an IterableList."""
160-
161-
__slots__= ("name",)
162-
163-
def__init__(self,name):
164-
self.name=name
165-
166-
def__repr__(self):
167-
returnf"{type(self).__name__}({self.name!r})"
168-
158+
classTestEnvParsing:
159+
"""Tests for environment variable parsing logic in :mod:`git.util`."""
160+
161+
@staticmethod
162+
def_run_parse(name,value):
163+
command= [
164+
sys.executable,
165+
"-c",
166+
f"from git.util import{name}; print(repr({name}))",
167+
]
168+
output=subprocess.check_output(
169+
command,
170+
env=NoneifvalueisNoneelsedict(os.environ,**{name:value}),
171+
text=True,
172+
)
173+
returnast.literal_eval(output)
169174

170-
@ddt.ddt
171-
classTestUtils(TestBase):
172-
"""Tests for utilities in :mod:`git.util` other than :func:`git.util.rmtree`."""
173-
174-
@ddt.data("HIDE_WINDOWS_KNOWN_ERRORS","HIDE_WINDOWS_FREEZE_ERRORS")
175-
deftest_env_vars_for_windows_tests(self,name):
176-
defrun_parse(value):
177-
command= [
178-
sys.executable,
179-
"-c",
180-
f"from git.util import{name}; print(repr({name}))",
181-
]
182-
output=subprocess.check_output(
183-
command,
184-
env=NoneifvalueisNoneelsedict(os.environ,**{name:value}),
185-
text=True,
186-
)
187-
returnast.literal_eval(output)
188-
189-
forenv_var_value,expected_truth_valuein (
175+
@pytest.mark.parametrize(
176+
"env_var_value, expected_truth_value",
177+
[
190178
(None,os.name=="nt"),# True on Windows when the environment variable is unset.
191179
("",False),
192180
(" ",False),
@@ -202,9 +190,35 @@ def run_parse(value):
202190
("YES",os.name=="nt"),
203191
(" no ",False),
204192
(" yes ",os.name=="nt"),
205-
):
206-
withself.subTest(env_var_value=env_var_value):
207-
self.assertIs(run_parse(env_var_value),expected_truth_value)
193+
],
194+
)
195+
@pytest.mark.parametrize(
196+
"name",
197+
[
198+
"HIDE_WINDOWS_KNOWN_ERRORS",
199+
"HIDE_WINDOWS_FREEZE_ERRORS",
200+
],
201+
)
202+
deftest_env_vars_for_windows_tests(self,name,env_var_value,expected_truth_value):
203+
actual_parsed_value=self._run_parse(name,env_var_value)
204+
assertactual_parsed_valueisexpected_truth_value
205+
206+
207+
class_Member:
208+
"""A member of an IterableList."""
209+
210+
__slots__= ("name",)
211+
212+
def__init__(self,name):
213+
self.name=name
214+
215+
def__repr__(self):
216+
returnf"{type(self).__name__}({self.name!r})"
217+
218+
219+
@ddt.ddt
220+
classTestUtils(TestBase):
221+
"""Tests for most utilities in :mod:`git.util`."""
208222

209223
_norm_cygpath_pairs= (
210224
(R"foo\bar","foo/bar"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp