|
10 | 10 | importsubprocess
|
11 | 11 | importsys
|
12 | 12 | fromtempfileimportTemporaryDirectory,TemporaryFile
|
13 |
| -fromunittestimportmock |
| 13 | +fromunittestimportmock,skipUnless |
14 | 14 |
|
15 | 15 | fromgitimportGit,refresh,GitCommandError,GitCommandNotFound,Repo,cmd
|
16 | 16 | fromtest.libimportTestBase,fixture_path
|
@@ -105,6 +105,27 @@ def test_it_executes_git_not_from_cwd(self):
|
105 | 105 | with_chdir(tmpdir):
|
106 | 106 | self.assertRegex(self.git.execute(["git","version"]),r"^git version\b")
|
107 | 107 |
|
| 108 | +@skipUnless(is_win,"The regression only affected Windows, and this test logic is OS-specific.") |
| 109 | +deftest_it_avoids_upcasing_unrelated_environment_variable_names(self): |
| 110 | +old_name="28f425ca_d5d8_4257_b013_8d63166c8158" |
| 111 | +ifold_name==old_name.upper(): |
| 112 | +raiseRuntimeError("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 | + |
108 | 129 | deftest_it_accepts_stdin(self):
|
109 | 130 | filename=fixture_path("cat_file_blob")
|
110 | 131 | withopen(filename,"r")asfh:
|
|