MCPcopy Index your code
hub / github.com/python/cpython / test_make_tarfile_without_rootdir

Method test_make_tarfile_without_rootdir

Lib/test/test_shutil.py:1682–1708  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1680
1681 @support.requires_zlib()
1682 def test_make_tarfile_without_rootdir(self):
1683 root_dir, base_dir = self._create_files()
1684 # Test without base_dir.
1685 base_name = os.path.join(self.mkdtemp(), 'dst', 'archive')
1686 base_name = os.path.relpath(base_name, root_dir)
1687 with os_helper.change_cwd(root_dir), no_chdir:
1688 archive = make_archive(base_name, 'gztar')
1689 self.assertEqual(archive, base_name + '.tar.gz')
1690 self.assertTrue(os.path.isfile(archive))
1691 self.assertTrue(tarfile.is_tarfile(archive))
1692 with tarfile.open(archive, 'r:gz') as tf:
1693 self.assertCountEqual(tf.getnames(),
1694 ['.', './dist', './dist/sub', './dist/sub2',
1695 './dist/file1', './dist/file2', './dist/sub/file3',
1696 './outer'])
1697
1698 # Test with base_dir.
1699 with os_helper.change_cwd(root_dir), no_chdir:
1700 base_name = os.path.join('dst', 'archive')
1701 archive = make_archive(base_name, 'tar', base_dir=base_dir)
1702 self.assertEqual(archive, base_name + '.tar')
1703 self.assertTrue(os.path.isfile(archive))
1704 self.assertTrue(tarfile.is_tarfile(archive))
1705 with tarfile.open(archive, 'r') as tf:
1706 self.assertCountEqual(tf.getnames(),
1707 ['dist', 'dist/sub', 'dist/sub2',
1708 'dist/file1', 'dist/file2', 'dist/sub/file3'])
1709
1710 def test_make_tarfile_with_explicit_curdir(self):
1711 # Test with base_dir=os.curdir.

Callers

nothing calls this directly

Calls 10

_create_filesMethod · 0.95
make_archiveFunction · 0.90
mkdtempMethod · 0.80
assertTrueMethod · 0.80
assertCountEqualMethod · 0.80
getnamesMethod · 0.80
joinMethod · 0.45
assertEqualMethod · 0.45
isfileMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected