def check_writing(self, treeish, timestamp=None): archive = tarfile.open('foo.tar', mode='w') self.repo.write_archive(treeish, archive) index = Index() if isinstance(treeish, Object): index.read_tree(treeish.peel(Tree)) else: index.read_tree(self.repo[treeish].peel(Tree)) self.assertEqual(len(index), len(archive.getmembers())) if timestamp: fileinfo = archive.getmembers()[0] self.assertEqual(timestamp, fileinfo.mtime) archive.close() self.assertTrue(os.path.isfile('foo.tar')) os.remove('foo.tar')
def check_writing(self, treeish, timestamp=None): archive = tarfile.open('foo.tar', mode='w') self.repo.write_archive(treeish, archive) index = Index() if isinstance(treeish, Object): index.read_tree(treeish.peel(Tree)) else: index.read_tree(self.repo[treeish].peel(Tree)) assert len(index) == len(archive.getmembers()) if timestamp: fileinfo = archive.getmembers()[0] assert timestamp == fileinfo.mtime archive.close() assert os.path.isfile('foo.tar') os.remove('foo.tar')
def test_create_empty_read_tree(self): index = Index() index.read_tree(self.repo['fd937514cb799514d4b81bb24c5fcfeb6472b245'])