Skip to content

Commit f1b8d0c

Browse files
committed
Add a test for persistent git options
1 parent 5b4f92c commit f1b8d0c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

git/cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def set_persistent_git_options(self, **kwargs):
415415
"""
416416

417417
self._persistent_git_options = self.transform_kwargs(
418-
split_single_char_options=True, **kwargs)
418+
split_single_char_options=True, **kwargs)
419419

420420
def _set_cache_(self, attr):
421421
if attr == '_version_info':

git/test/test_git.py

+14
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,20 @@ def test_options_are_passed_to_git(self):
160160
git_command_version = self.git.version()
161161
self.assertEquals(git_version, git_command_version)
162162

163+
def test_persistent_options(self):
164+
git_command_version = self.git.version()
165+
# analog to test_options_are_passed_to_git
166+
self.git.set_persistent_git_options(version=True)
167+
git_version = self.git.NoOp()
168+
self.assertEquals(git_version, git_command_version)
169+
# subsequent calls keep this option:
170+
git_version_2 = self.git.NoOp()
171+
self.assertEquals(git_version_2, git_command_version)
172+
173+
# reset to empty:
174+
self.git.set_persistent_git_options()
175+
self.assertRaises(GitCommandError, self.git.NoOp)
176+
163177
def test_single_char_git_options_are_passed_to_git(self):
164178
input_value = 'TestValue'
165179
output_value = self.git(c='user.name=%s' % input_value).config('--get', 'user.name')

0 commit comments

Comments
 (0)