def test_copy_symlink(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))
# Create a symlink to the sparse file.
linked_file = os.path.join(tmpdir, 'linked.dat')
os.symlink(sparse_file, linked_file)
self.assertTrue(os.path.islink(linked_file))
copied_link = os.path.join(tmpdir, 'copied.dat')
sparse_copy(linked_file, copied_link, follow_symlinks=False)
self.assertTrue(os.path.islink(copied_link))
评论列表
文章目录