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 7296e5c

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

File tree

2 files changed

+18
-9
lines changed
Filter options

2 files changed

+18
-9
lines changed

‎test/fixtures/env_case.py

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
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

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