def test_sparse_copy(self):
with ExitStack() as resources:
tmpdir = resources.enter_context(TemporaryDirectory())
sparse_file = os.path.join(tmpdir, 'sparse.dat')
fp = resources.enter_context(open(sparse_file, 'w'))
os.truncate(fp.fileno(), 1000000)
# This file is sparse.
self.assertTrue(is_sparse(sparse_file))
copied_file = os.path.join(tmpdir, 'copied.dat')
sparse_copy(sparse_file, copied_file)
self.assertTrue(is_sparse(copied_file))
评论列表
文章目录