| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e2fa5e2 commit c4da058
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,5 +8,4 @@ pytest >= 7.3.1 | |||
| 8 | 8 | pytest-cov | |
| 9 | 9 | pytest-instafail | |
| 10 | 10 | pytest-mock | |
| 11 | - pytest-subtests | ||
| 12 | 11 | pytest-sugar | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,38 +155,26 @@ def test_does_not_wrap_other_errors(self, mocker, file_not_found_tmpdir, hide_wi | |||
| 155 | 155 | self.fail(f"rmtree unexpectedly attempts skip: {ex!r}") | |
| 156 | 156 | ||
| 157 | 157 | ||
| 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 | - return f"{type(self).__name__}({self.name!r})" | ||
| 168 | - | ||
| 158 | + class TestEnvParsing: | ||
| 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=None if value is None else dict(os.environ, **{name: value}), | ||
| 171 | + text=True, | ||
| 172 | + ) | ||
| 173 | + return ast.literal_eval(output) | ||
| 169 | 174 | ||
| 170 | - @ddt.ddt | ||
| 171 | - class TestUtils(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 | - def test_env_vars_for_windows_tests(self, name): | ||
| 176 | - def run_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=None if value is None else dict(os.environ, **{name: value}), | ||
| 185 | - text=True, | ||
| 186 | - ) | ||
| 187 | - return ast.literal_eval(output) | ||
| 188 | - | ||
| 189 | - for env_var_value, expected_truth_value in ( | ||
| 175 | + @pytest.mark.parametrize( | ||
| 176 | + "env_var_value, expected_truth_value", | ||
| 177 | + [ | ||
| 190 | 178 | (None, os.name == "nt"), # True on Windows when the environment variable is unset. | |
| 191 | 179 | ("", False), | |
| 192 | 180 | (" ", False), | |
@@ -202,9 +190,35 @@ def run_parse(value): | |||
| 202 | 190 | ("YES", os.name == "nt"), | |
| 203 | 191 | (" no ", False), | |
| 204 | 192 | (" yes ", os.name == "nt"), | |
| 205 | - ): | ||
| 206 | - with self.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 | + def test_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 | + assert actual_parsed_value is expected_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 | + return f"{type(self).__name__}({self.name!r})" | ||
| 217 | + | ||
| 218 | + | ||
| 219 | + @ddt.ddt | ||
| 220 | + class TestUtils(TestBase): | ||
| 221 | + """Tests for most utilities in :mod:`git.util`.""" | ||
| 208 | 222 | ||
| 209 | 223 | _norm_cygpath_pairs = ( | |
| 210 | 224 | (R"foo\bar", "foo/bar"), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments