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

Appearance settings

Commit d88372a

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

File tree

1 file changed

+22
-1
lines changed
Filter options

1 file changed

+22
-1
lines changed

‎test/test_git.py

Copy file name to clipboardExpand all lines: test/test_git.py
+22-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.