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

Method test_zipfile_vs_zip

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

Source from the content-addressed store, hash-verified

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'),

Callers

nothing calls this directly

Calls 8

_create_filesMethod · 0.95
make_archiveFunction · 0.90
mkdtempMethod · 0.80
assertTrueMethod · 0.80
joinMethod · 0.45
assertEqualMethod · 0.45
isfileMethod · 0.45
namelistMethod · 0.45

Tested by

no test coverage detected