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

Commitc11b366

Browse files
committed
Simplify HIDE_* env var test; add missing cases
Now that the expected truth values are intuitive, it is no longernecessary to group them by result and include messages thatacknowldge the unintuitive cases. This reorders them so that pairs(like "yes" and "no") appear together, removes the messages thatare no longer necessary, and reduces test code duplication.This also adds cases to test leading/trailing whitespace inotherwise nonempty strings, so it is clearer what the test isasserting overall, and so a bug where lstrip or rstrip (orequivalent with a regex) were used instead strip would be caught.
1 parent333896b commitc11b366

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

‎test/test_util.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -520,30 +520,22 @@ def run_parse(value):
520520
)
521521
returnast.literal_eval(output)
522522

523-
true_iff_win=os.name=="nt"# Same as is_win, but don't depend on that here.
524-
525-
truthy_cases= [
526-
("unset",None),
527-
("true-seeming","1"),
528-
("true-seeming","true"),
529-
("true-seeming","True"),
530-
("true-seeming","yes"),
531-
("true-seeming","YES"),
532-
]
533-
falsy_cases= [
534-
("empty",""),
535-
("whitespace"," "),
536-
("false-seeming","0"),
537-
("false-seeming","false"),
538-
("false-seeming","False"),
539-
("false-seeming","no"),
540-
("false-seeming","NO"),
541-
]
542-
543-
formsg,env_var_valueintruthy_cases:
544-
withself.subTest(msg,env_var_value=env_var_value):
545-
self.assertIs(run_parse(env_var_value),true_iff_win)
546-
547-
formsg,env_var_valueinfalsy_cases:
548-
withself.subTest(msg,env_var_value=env_var_value):
549-
self.assertIs(run_parse(env_var_value),False)
523+
forenv_var_value,expected_truth_valuein (
524+
(None,os.name=="nt"),# True on Windows when the environment variable is unset.
525+
("",False),
526+
(" ",False),
527+
("0",False),
528+
("1",os.name=="nt"),
529+
("false",False),
530+
("true",os.name=="nt"),
531+
("False",False),
532+
("True",os.name=="nt"),
533+
("no",False),
534+
("yes",os.name=="nt"),
535+
("NO",False),
536+
("YES",os.name=="nt"),
537+
(" no ",False),
538+
(" yes ",os.name=="nt"),
539+
):
540+
withself.subTest(env_var_value=env_var_value):
541+
self.assertIs(run_parse(env_var_value),expected_truth_value)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp