Skip to content

Commit 14055f5

Browse files
committed
Test that version_info is not pickled
That is, that its value is not pickle serialized/deserialized, but always recomputed with a subprocess call the first time it is accessed even on a Git instance that is created by unpickling.
1 parent f1cc524 commit 14055f5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: test/test_git.py

+12
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,18 @@ def test_version_info_cache_is_per_instance(self):
533533
git2.version_info
534534
git1.version_info
535535

536+
def test_version_info_cache_is_not_pickled(self):
537+
with _rollback_refresh():
538+
with _fake_git(123, 456, 789) as path:
539+
git1 = Git()
540+
refresh(path)
541+
git1.version_info
542+
git2 = pickle.loads(pickle.dumps(git1))
543+
os.remove(path) # Arrange that the second subprocess call will fail.
544+
with self.assertRaises(GitCommandNotFound):
545+
git2.version_info
546+
git1.version_info
547+
536548
def test_successful_refresh_with_arg_invalidates_cached_version_info(self):
537549
with _rollback_refresh():
538550
with _fake_git(11, 111, 1) as path1:

0 commit comments

Comments
 (0)