Skip to content

Commit

Permalink
Extend test_cmd_override to test exception's command attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
EliahKagan committed Feb 6, 2024
1 parent db6fb90 commit 85ef145
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,17 @@ def test_version(self):
self.assertIsInstance(n, int)
# END verify number types

def test_cmd_override(self):
with mock.patch.object(
type(self.git),
"GIT_PYTHON_GIT_EXECUTABLE",
osp.join("some", "path", "which", "doesn't", "exist", "gitbinary"),
):
self.assertRaises(GitCommandNotFound, self.git.version)

def test_git_exc_name_is_git(self):
self.assertEqual(self.git.git_exec_name, "git")

def test_cmd_override(self):
"""Directly set bad GIT_PYTHON_GIT_EXECUTABLE causes git operations to raise."""
bad_path = osp.join("some", "path", "which", "doesn't", "exist", "gitbinary")
with mock.patch.object(type(self.git), "GIT_PYTHON_GIT_EXECUTABLE", bad_path):
with self.assertRaises(GitCommandNotFound) as ctx:
self.git.version()
self.assertEqual(ctx.exception.command, [bad_path, "version"])

@ddt.data(("0",), ("q",), ("quiet",), ("s",), ("silence",), ("silent",), ("n",), ("none",))
def test_initial_refresh_from_bad_git_path_env_quiet(self, case):
"""In "q" mode, bad initial path sets "git" and is quiet."""
Expand Down

0 comments on commit 85ef145

Please sign in to comment.