Skip to content

Commit

Permalink
Make test helper script a file, for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
EliahKagan committed Sep 7, 2023
1 parent d88372a commit 7296e5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 13 additions & 0 deletions test/fixtures/env_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import subprocess
import sys

import git


_, working_dir, env_var_name = sys.argv

# Importing git should be enough, but this really makes sure Git.execute is called.
repo = git.Repo(working_dir) # Hold the reference.
git.Git(repo.working_dir).execute(["git", "version"])

print(subprocess.check_output(["set", env_var_name], shell=True, text=True))
14 changes: 5 additions & 9 deletions test/test_git.py
Original file line number Diff line number Diff line change
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")
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

0 comments on commit 7296e5c

Please sign in to comment.