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

Commit100ab98

Browse files
committed
Add initial test_env_vars_for_windows_tests
The new test method just verifies the current behavior of theHIDE_WINDOWS_KNOWN_ERRORS and HIDE_WINDOWS_FREEZE_ERRORSenvironment variables. This is so there is a test to modify whenchanging that behavior. The purpose of these tests is *not* toclaim that the behavior of either variable is something code thatuses GitPython can (or has ever been able to) rely on.This also adds pytest-subtests as a dependency, so multiplefailures from the subtests can be seen in the same test run.
1 parent196cfbe commit100ab98

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

‎test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ pre-commit
77
pytest
88
pytest-cov
99
pytest-instafail
10+
pytest-subtests
1011
pytest-sugar

‎test/test_util.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: https://opensource.org/license/bsd-3-clause/
66

7+
importast
78
importcontextlib
89
fromdatetimeimportdatetime
910
importos
1011
importpathlib
1112
importpickle
1213
importstat
14+
importsubprocess
1315
importsys
1416
importtempfile
1517
importtime
@@ -502,3 +504,46 @@ def test_remove_password_from_command_line(self):
502504

503505
assertcmd_4==remove_password_if_present(cmd_4)
504506
assertcmd_5==remove_password_if_present(cmd_5)
507+
508+
@ddt.data("HIDE_WINDOWS_KNOWN_ERRORS","HIDE_WINDOWS_FREEZE_ERRORS")
509+
deftest_env_vars_for_windows_tests(self,name):
510+
defrun_parse(value):
511+
command= [
512+
sys.executable,
513+
"-c",
514+
f"from git.util import{name}; print(repr({name}))",
515+
]
516+
output=subprocess.check_output(
517+
command,
518+
env=NoneifvalueisNoneelsedict(os.environ,**{name:value}),
519+
text=True,
520+
)
521+
returnast.literal_eval(output)
522+
523+
assert_true_iff_win=self.assertTrueifos.name=="nt"elseself.assertFalse
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+
("false-seeming","0"),
533+
("false-seeming","false"),
534+
("false-seeming","False"),
535+
("false-seeming","no"),
536+
("false-seeming","NO"),
537+
("whitespace"," "),
538+
]
539+
falsy_cases= [
540+
("empty",""),
541+
]
542+
543+
formsg,env_var_valueintruthy_cases:
544+
withself.subTest(msg,env_var_value=env_var_value):
545+
assert_true_iff_win(run_parse(env_var_value))
546+
547+
formsg,env_var_valueinfalsy_cases:
548+
withself.subTest(msg,env_var_value=env_var_value):
549+
self.assertFalse(run_parse(env_var_value))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp