Skip to content

Commit

Permalink
Run test_env_vars_for_windows_tests only on Windows
Browse files Browse the repository at this point in the history
This skips the tests of how the HIDE_WINDOWS_KNOWN_ERRORS and
HIDE_WINDOWS_FREEZE_ERRORS environment variables affect the
same-named attributes of git.util, except when testing on Windows.

These are parsed only to ever set a True value on Windows, but
checking that this is the case is less important ever since
git.util.rmtree was changed to not check HIDE_WINDOWS_KNOWN_ERRORS
on other systems (and this is covered in other tests).

Setting the variables to True on non-Windows systems would still
have a bad effect on the tests themselves, some of which use them
as skip or xfail conditions separate from the skipping logic in
git.util.rmtree. However, this is effectively using them as part of
the test suite (which they were initially meant for and which they
may eventually go back to being, for gitpython-developers#790), where they would not
ordinarily have tests.

The benefit and motivation for running these tests only on Windows
is that the tests can be simplified, so that their parameter sets
are no longer confusing. That change is also made here.
  • Loading branch information
EliahKagan committed Dec 19, 2023
1 parent b12a54a commit 6a8ed70
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,28 @@ def _run_parse(name, value):
)
return ast.literal_eval(output)

@pytest.mark.skipif(
os.name != "nt",
reason="These environment variables are only used on Windows.",
)
@pytest.mark.parametrize(
"env_var_value, expected_truth_value",
[
(None, os.name == "nt"), # True on Windows when the environment variable is unset.
(None, True), # When the environment variable is unset.
("", False),
(" ", False),
("0", False),
("1", os.name == "nt"),
("1", True),
("false", False),
("true", os.name == "nt"),
("true", True),
("False", False),
("True", os.name == "nt"),
("True", True),
("no", False),
("yes", os.name == "nt"),
("yes", True),
("NO", False),
("YES", os.name == "nt"),
("YES", True),
(" no ", False),
(" yes ", os.name == "nt"),
(" yes ", True),
],
)
@pytest.mark.parametrize(
Expand Down

0 comments on commit 6a8ed70

Please sign in to comment.