Skip to content

Commit 2eac36c

Browse files
committed
Have _fake_git fixture take version_info
This reorganization is to facilitate using two separate fake git commands with different versions, in forthcoming tests.
1 parent 3f107d5 commit 2eac36c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/test_git.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
from git.util import cwd, finalize_process
2929
from test.lib import TestBase, fixture_path, with_rw_directory
3030

31-
_FAKE_GIT_VERSION_INFO = (123, 456, 789)
32-
3331

3432
@contextlib.contextmanager
3533
def _patch_out_env(name):
@@ -70,8 +68,8 @@ def _rollback_refresh():
7068

7169

7270
@contextlib.contextmanager
73-
def _fake_git():
74-
fake_version = ".".join(str(field) for field in _FAKE_GIT_VERSION_INFO)
71+
def _fake_git(*version_info):
72+
fake_version = ".".join(map(str, version_info))
7573
fake_output = f"git version {fake_version} (fake)"
7674

7775
with tempfile.TemporaryDirectory() as tdir:
@@ -505,17 +503,18 @@ def test_refresh_with_good_relative_git_path_arg(self):
505503
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
506504

507505
def test_version_info_is_cached(self):
506+
fake_version_info = (123, 456, 789)
508507
with _rollback_refresh():
509-
with _fake_git() as path:
508+
with _fake_git(*fake_version_info) as path:
510509
new_git = Git() # Not cached yet.
511510
refresh(path)
512-
self.assertEqual(new_git.version_info, _FAKE_GIT_VERSION_INFO)
511+
self.assertEqual(new_git.version_info, fake_version_info)
513512
os.remove(path) # Arrange that a second subprocess call would fail.
514-
self.assertEqual(new_git.version_info, _FAKE_GIT_VERSION_INFO)
513+
self.assertEqual(new_git.version_info, fake_version_info)
515514

516515
def test_version_info_cache_is_per_instance(self):
517516
with _rollback_refresh():
518-
with _fake_git() as path:
517+
with _fake_git(123, 456, 789) as path:
519518
git1 = Git()
520519
git2 = Git()
521520
refresh(path)

0 commit comments

Comments
 (0)