Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f107d5

Browse files
committed
Test that version_info caching is per instance
This independence is also established caching behavior forversion_info.
1 parent1de2fdc commit3f107d5

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

‎test/test_git.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
fromgit.utilimportcwd,finalize_process
2929
fromtest.libimportTestBase,fixture_path,with_rw_directory
3030

31+
_FAKE_GIT_VERSION_INFO= (123,456,789)
32+
3133

3234
@contextlib.contextmanager
3335
def_patch_out_env(name):
@@ -69,7 +71,8 @@ def _rollback_refresh():
6971

7072
@contextlib.contextmanager
7173
def_fake_git():
72-
fake_output="git version 123.456.789 (fake)"
74+
fake_version=".".join(str(field)forfieldin_FAKE_GIT_VERSION_INFO)
75+
fake_output=f"git version{fake_version} (fake)"
7376

7477
withtempfile.TemporaryDirectory()astdir:
7578
ifos.name=="nt":
@@ -506,10 +509,21 @@ def test_version_info_is_cached(self):
506509
with_fake_git()aspath:
507510
new_git=Git()# Not cached yet.
508511
refresh(path)
509-
version_info=new_git.version_info# Caches the value.
510-
self.assertEqual(version_info, (123,456,789))
511-
os.remove(path)# Arrange that reading a second time would fail.
512-
self.assertEqual(new_git.version_info,version_info)# Cached value.
512+
self.assertEqual(new_git.version_info,_FAKE_GIT_VERSION_INFO)
513+
os.remove(path)# Arrange that a second subprocess call would fail.
514+
self.assertEqual(new_git.version_info,_FAKE_GIT_VERSION_INFO)
515+
516+
deftest_version_info_cache_is_per_instance(self):
517+
with_rollback_refresh():
518+
with_fake_git()aspath:
519+
git1=Git()
520+
git2=Git()
521+
refresh(path)
522+
git1.version_info
523+
os.remove(path)# Arrange that the second subprocess call will fail.
524+
withself.assertRaises(GitCommandNotFound):
525+
git2.version_info
526+
git1.version_info
513527

514528
deftest_options_are_passed_to_git(self):
515529
# This works because any command after git --version is ignored.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp