(self)
| 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. |
nothing calls this directly
no test coverage detected