(self)
| 1638 | |
| 1639 | @support.requires_zlib() |
| 1640 | def test_make_tarfile(self): |
| 1641 | root_dir, base_dir = self._create_files() |
| 1642 | # Test without base_dir. |
| 1643 | with os_helper.temp_cwd(), no_chdir: |
| 1644 | base_name = os.path.join('dst', 'archive') |
| 1645 | archive = make_archive(base_name, 'tar', root_dir) |
| 1646 | # check if the compressed tarball was created |
| 1647 | self.assertEqual(archive, os.path.abspath(base_name) + '.tar') |
| 1648 | self.assertTrue(os.path.isfile(archive)) |
| 1649 | self.assertTrue(tarfile.is_tarfile(archive)) |
| 1650 | with tarfile.open(archive, 'r') as tf: |
| 1651 | self.assertCountEqual(tf.getnames(), |
| 1652 | ['.', './dist', './dist/sub', './dist/sub2', |
| 1653 | './dist/file1', './dist/file2', './dist/sub/file3', |
| 1654 | './outer']) |
| 1655 | |
| 1656 | # Test with base_dir. |
| 1657 | with os_helper.temp_cwd(), no_chdir: |
| 1658 | base_name = os.path.join('dst2', 'archive') |
| 1659 | archive = make_archive(base_name, 'tar', root_dir, base_dir) |
| 1660 | self.assertEqual(archive, os.path.abspath(base_name) + '.tar') |
| 1661 | # check if the uncompressed tarball was created |
| 1662 | self.assertTrue(os.path.isfile(archive)) |
| 1663 | self.assertTrue(tarfile.is_tarfile(archive)) |
| 1664 | with tarfile.open(archive, 'r') as tf: |
| 1665 | self.assertCountEqual(tf.getnames(), |
| 1666 | ['dist', 'dist/sub', 'dist/sub2', |
| 1667 | 'dist/file1', 'dist/file2', 'dist/sub/file3']) |
| 1668 | |
| 1669 | # Test with multi-component base_dir. |
| 1670 | with os_helper.temp_cwd(), no_chdir: |
| 1671 | base_name = os.path.join('dst3', 'archive') |
| 1672 | archive = make_archive(base_name, 'tar', root_dir, |
| 1673 | os.path.join(base_dir, 'sub')) |
| 1674 | self.assertEqual(archive, os.path.abspath(base_name) + '.tar') |
| 1675 | self.assertTrue(os.path.isfile(archive)) |
| 1676 | self.assertTrue(tarfile.is_tarfile(archive)) |
| 1677 | with tarfile.open(archive, 'r') as tf: |
| 1678 | self.assertCountEqual(tf.getnames(), |
| 1679 | ['dist/sub', 'dist/sub/file3']) |
| 1680 | |
| 1681 | @support.requires_zlib() |
| 1682 | def test_make_tarfile_without_rootdir(self): |
nothing calls this directly
no test coverage detected