Skip to content

Report actual attempted Git command when Git.refresh fails #1812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 26, 2024
Prev Previous commit
Next Next commit
Have test of refresh that should fail assert command
This extends test_refresh_bad_git_path so that it asserts that the
exception message shows the command the failed refresh used.

This test fails due to a bug where "git" is always shown (#1809).
  • Loading branch information
EliahKagan committed Jan 24, 2024
commit f98aadddfe390348c2858690fec9577301ea9ba9
6 changes: 5 additions & 1 deletion test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ def test_cmd_override(self):
self.assertRaises(GitCommandNotFound, self.git.version)

def test_refresh_bad_git_path(self):
self.assertRaises(GitCommandNotFound, refresh, "yada")
path = "yada"
escaped_abspath = re.escape(str(Path(path).absolute()))
expected_pattern = rf"\n[ \t]*cmdline: {escaped_abspath}\Z"
with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
refresh(path)

def test_refresh_good_git_path(self):
path = shutil.which("git")
Expand Down