Skip to content

Commit d88372a

Browse files
committed
Add test for Windows env var upcasing regression
1 parent 11839ab commit d88372a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/test_git.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import subprocess
1111
import sys
1212
from tempfile import TemporaryDirectory, TemporaryFile
13-
from unittest import mock
13+
from unittest import mock, skipUnless
1414

1515
from git import Git, refresh, GitCommandError, GitCommandNotFound, Repo, cmd
1616
from test.lib import TestBase, fixture_path
@@ -105,6 +105,27 @@ def test_it_executes_git_not_from_cwd(self):
105105
with _chdir(tmpdir):
106106
self.assertRegex(self.git.execute(["git", "version"]), r"^git version\b")
107107

108+
@skipUnless(is_win, "The regression only affected Windows, and this test logic is OS-specific.")
109+
def test_it_avoids_upcasing_unrelated_environment_variable_names(self):
110+
old_name = "28f425ca_d5d8_4257_b013_8d63166c8158"
111+
if old_name == old_name.upper():
112+
raise RuntimeError("test bug or strange locale: old_name invariant under upcasing")
113+
os.putenv(old_name, "1") # It has to be done this lower-level way to set it lower-case.
114+
115+
script_lines = [
116+
"import subprocess, git",
117+
118+
# Importing git should be enough, but this really makes sure Git.execute is called.
119+
f"repo = git.Repo({self.rorepo.working_dir!r})",
120+
"git.Git(repo.working_dir).execute(['git', 'version'])",
121+
122+
f"print(subprocess.check_output(['set', {old_name!r}], shell=True, text=True))",
123+
]
124+
cmdline = [sys.executable, "-c", "\n".join(script_lines)]
125+
pair_text = subprocess.check_output(cmdline, shell=False, text=True)
126+
new_name = pair_text.split("=")[0]
127+
self.assertEqual(new_name, old_name)
128+
108129
def test_it_accepts_stdin(self):
109130
filename = fixture_path("cat_file_blob")
110131
with open(filename, "r") as fh:

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