Fix Windows environment variable upcasing bug by EliahKagan · Pull Request #1650 · gitpython-developers/GitPython (original) (raw)

Expand Up

@@ -112,16 +112,12 @@ def test_it_avoids_upcasing_unrelated_environment_variable_names(self):

raise RuntimeError("test bug or strange locale: old_name invariant under upcasing")

Byron marked this conversation as resolved.

Show resolved Hide resolved

os.putenv(old_name, "1") # It has to be done this lower-level way to set it lower-case.

script_lines = [

"import subprocess, git",

# Importing git should be enough, but this really makes sure Git.execute is called.

f"repo = git.Repo({self.rorepo.working_dir!r})",

"git.Git(repo.working_dir).execute(['git', 'version'])",

f"print(subprocess.check_output(['set', {old_name!r}], shell=True, text=True))",

cmdline = [

sys.executable,

fixture_path("env_case.py"),

self.rorepo.working_dir,

old_name,

]

cmdline = [sys.executable, "-c", "\n".join(script_lines)]

pair_text = subprocess.check_output(cmdline, shell=False, text=True)

new_name = pair_text.split("=")[0]

self.assertEqual(new_name, old_name)

Expand Down