Skip to content

Commit a8a43fe

Browse files
committed
Simplify shell test helper with with_exceptions=False
Instead of swallowing GitCommandError exceptions in the helper used by test_it_uses_shell_or_not_as_specified and test_it_logs_if_it_uses_a_shell, this modifies the helper so it prevents Git.execute from raising the exception in the first place.
1 parent 2d1efdc commit a8a43fe

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Diff for: test/test_git.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#
55
# This module is part of GitPython and is released under
66
# the BSD License: https://opensource.org/license/bsd-3-clause/
7-
import contextlib
87
import inspect
98
import logging
109
import os
@@ -97,10 +96,8 @@ def _do_shell_combo(self, value_in_call, value_from_class):
9796
# git.cmd gets Popen via a "from" import, so patch it there.
9897
with mock.patch.object(cmd, "Popen", wraps=cmd.Popen) as mock_popen:
9998
# Use a command with no arguments (besides the program name), so it runs
100-
# with or without a shell, on all OSes, with the same effect. Since git
101-
# errors out when run with no arguments, we swallow that error.
102-
with contextlib.suppress(GitCommandError):
103-
self.git.execute(["git"], shell=value_in_call)
99+
# with or without a shell, on all OSes, with the same effect.
100+
self.git.execute(["git"], with_exceptions=False, shell=value_in_call)
104101

105102
return mock_popen
106103

0 commit comments

Comments
 (0)