Skip to content

Fix bugs affecting exception wrapping in rmtree callback #1700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify HIDE_* env var test; add missing cases
Now that the expected truth values are intuitive, it is no longer
necessary to group them by result and include messages that
acknowldge the unintuitive cases. This reorders them so that pairs
(like "yes" and "no") appear together, removes the messages that
are no longer necessary, and reduces test code duplication.

This also adds cases to test leading/trailing whitespace in
otherwise nonempty strings, so it is clearer what the test is
asserting overall, and so a bug where lstrip or rstrip (or
equivalent with a regex) were used instead strip would be caught.
  • Loading branch information
EliahKagan committed Oct 9, 2023
commit c11b36660382c713709b36bbca1da8a1acb3a4ec
46 changes: 19 additions & 27 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,30 +520,22 @@ def run_parse(value):
)
return ast.literal_eval(output)

true_iff_win = os.name == "nt" # Same as is_win, but don't depend on that here.

truthy_cases = [
("unset", None),
("true-seeming", "1"),
("true-seeming", "true"),
("true-seeming", "True"),
("true-seeming", "yes"),
("true-seeming", "YES"),
]
falsy_cases = [
("empty", ""),
("whitespace", " "),
("false-seeming", "0"),
("false-seeming", "false"),
("false-seeming", "False"),
("false-seeming", "no"),
("false-seeming", "NO"),
]

for msg, env_var_value in truthy_cases:
with self.subTest(msg, env_var_value=env_var_value):
self.assertIs(run_parse(env_var_value), true_iff_win)

for msg, env_var_value in falsy_cases:
with self.subTest(msg, env_var_value=env_var_value):
self.assertIs(run_parse(env_var_value), False)
for env_var_value, expected_truth_value in (
(None, os.name == "nt"), # True on Windows when the environment variable is unset.
("", False),
(" ", False),
("0", False),
("1", os.name == "nt"),
("false", False),
("true", os.name == "nt"),
("False", False),
("True", os.name == "nt"),
("no", False),
("yes", os.name == "nt"),
("NO", False),
("YES", os.name == "nt"),
(" no ", False),
(" yes ", os.name == "nt"),
):
with self.subTest(env_var_value=env_var_value):
self.assertIs(run_parse(env_var_value), expected_truth_value)