Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions test_git_fetch_file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import unittest
import subprocess
import tempfile
Expand All @@ -14,8 +15,11 @@ def test_argparse_argumentparser(self):
script_path = subprocess.check_output(
["git", "config", "alias.fetch-file"], text=True
).strip()
if script_path.startswith("!python3 "):
script_path = script_path[len("!python3 "):]
# remove any leading "!something " prefix
script_path = re.sub(r"^!\S+\s+", "", script_path)
# when this is actually git-bash.exe, the path may need to be translated
if os.name == 'nt' and script_path.startswith('/'):
script_path = script_path[1] + ':' + script_path[2:]
with open(script_path, "r") as f:
source = f.read()
self.assertIn("argparse.ArgumentParser", source, "failed to find argparse.ArgumentParser")
Expand All @@ -31,8 +35,8 @@ def setUp(self):
subprocess.run(["git", "config", "user.email", "test@example.com"], check=True)

def tearDown(self):
shutil.rmtree(self.tmpdir)
os.chdir(self.oldpwd)
shutil.rmtree(self.tmpdir)


class TestAdd(TestGitRepository):
Expand Down