Skip to content

Commit 100ab98

Browse files
committed
Add initial test_env_vars_for_windows_tests
The new test method just verifies the current behavior of the HIDE_WINDOWS_KNOWN_ERRORS and HIDE_WINDOWS_FREEZE_ERRORS environment variables. This is so there is a test to modify when changing that behavior. The purpose of these tests is *not* to claim that the behavior of either variable is something code that uses GitPython can (or has ever been able to) rely on. This also adds pytest-subtests as a dependency, so multiple failures from the subtests can be seen in the same test run.
1 parent 196cfbe commit 100ab98

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+
import ast
78
import contextlib
89
from datetime import datetime
910
import os
1011
import pathlib
1112
import pickle
1213
import stat
14+
import subprocess
1315
import sys
1416
import tempfile
1517
import time
@@ -502,3 +504,46 @@ def test_remove_password_from_command_line(self):
502504

503505
assert cmd_4 == remove_password_if_present(cmd_4)
504506
assert cmd_5 == remove_password_if_present(cmd_5)
507+
508+
@ddt.data("HIDE_WINDOWS_KNOWN_ERRORS", "HIDE_WINDOWS_FREEZE_ERRORS")
509+
def test_env_vars_for_windows_tests(self, name):
510+
def run_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=None if value is None else dict(os.environ, **{name: value}),
519+
text=True,
520+
)
521+
return ast.literal_eval(output)
522+
523+
assert_true_iff_win = self.assertTrue if os.name == "nt" else self.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+
for msg, env_var_value in truthy_cases:
544+
with self.subTest(msg, env_var_value=env_var_value):
545+
assert_true_iff_win(run_parse(env_var_value))
546+
547+
for msg, env_var_value in falsy_cases:
548+
with self.subTest(msg, env_var_value=env_var_value):
549+
self.assertFalse(run_parse(env_var_value))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy