Skip to content

Commit 7296e5c

Browse files
committed
Make test helper script a file, for readability
1 parent d88372a commit 7296e5c

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

test/fixtures/env_case.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import subprocess
2+
import sys
3+
4+
import git
5+
6+
7+
_, working_dir, env_var_name = sys.argv
8+
9+
# Importing git should be enough, but this really makes sure Git.execute is called.
10+
repo = git.Repo(working_dir) # Hold the reference.
11+
git.Git(repo.working_dir).execute(["git", "version"])
12+
13+
print(subprocess.check_output(["set", env_var_name], shell=True, text=True))

test/test_git.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,12 @@ def test_it_avoids_upcasing_unrelated_environment_variable_names(self):
112112
raise RuntimeError("test bug or strange locale: old_name invariant under upcasing")
113113
os.putenv(old_name, "1") # It has to be done this lower-level way to set it lower-case.
114114

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))",
115+
cmdline = [
116+
sys.executable,
117+
fixture_path("env_case.py"),
118+
self.rorepo.working_dir,
119+
old_name,
123120
]
124-
cmdline = [sys.executable, "-c", "\n".join(script_lines)]
125121
pair_text = subprocess.check_output(cmdline, shell=False, text=True)
126122
new_name = pair_text.split("=")[0]
127123
self.assertEqual(new_name, old_name)

0 commit comments

Comments
 (0)