(self)
| 1859 | @unittest.skipUnless(shutil.which('zip'), |
| 1860 | 'Need the zip command to run') |
| 1861 | def test_zipfile_vs_zip(self): |
| 1862 | root_dir, base_dir = self._create_files() |
| 1863 | base_name = os.path.join(self.mkdtemp(), 'archive') |
| 1864 | with no_chdir: |
| 1865 | archive = make_archive(base_name, 'zip', root_dir, base_dir) |
| 1866 | |
| 1867 | # check if ZIP file was created |
| 1868 | self.assertEqual(archive, base_name + '.zip') |
| 1869 | self.assertTrue(os.path.isfile(archive)) |
| 1870 | |
| 1871 | # now create another ZIP file using `zip` |
| 1872 | archive2 = os.path.join(root_dir, 'archive2.zip') |
| 1873 | zip_cmd = ['zip', '-q', '-r', 'archive2.zip', base_dir] |
| 1874 | subprocess.check_call(zip_cmd, cwd=root_dir, |
| 1875 | stdout=subprocess.DEVNULL) |
| 1876 | |
| 1877 | self.assertTrue(os.path.isfile(archive2)) |
| 1878 | # let's compare both ZIP files |
| 1879 | with zipfile.ZipFile(archive) as zf: |
| 1880 | names = zf.namelist() |
| 1881 | with zipfile.ZipFile(archive2) as zf: |
| 1882 | names2 = zf.namelist() |
| 1883 | self.assertEqual(sorted(names), sorted(names2)) |
| 1884 | |
| 1885 | @support.requires_zlib() |
| 1886 | @unittest.skipUnless(shutil.which('unzip'), |
nothing calls this directly
no test coverage detected