Skip to content

Commit 3a34dee

Browse files
committed
Also test refresh with an already-absolute bad path
1 parent 24d6067 commit 3a34dee

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Diff for: test/test_git.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,23 @@ def test_cmd_override(self):
306306
):
307307
self.assertRaises(GitCommandNotFound, self.git.version)
308308

309-
def test_refresh_bad_git_path(self):
310-
path = "yada"
311-
escaped_abspath = re.escape(str(Path(path).absolute()))
312-
expected_pattern = rf"\n[ \t]*cmdline: {escaped_abspath}\Z"
309+
def test_refresh_bad_absolute_git_path(self):
310+
absolute_path = str(Path("yada").absolute())
311+
expected_pattern = rf"\n[ \t]*cmdline: {re.escape(absolute_path)}\Z"
313312
with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
314-
refresh(path)
313+
refresh(absolute_path)
315314

316-
def test_refresh_good_git_path(self):
317-
path = shutil.which("git")
318-
refresh(path)
315+
def test_refresh_bad_relative_git_path(self):
316+
relative_path = "yada"
317+
absolute_path = str(Path(relative_path).absolute())
318+
expected_pattern = rf"\n[ \t]*cmdline: {re.escape(absolute_path)}\Z"
319+
with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
320+
refresh(relative_path)
321+
322+
def test_refresh_good_absolute_git_path(self):
323+
absolute_path = shutil.which("git")
324+
refresh(absolute_path)
325+
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
319326

320327
def test_options_are_passed_to_git(self):
321328
# This works because any command after git --version is ignored.

0 commit comments

Comments
 (0)