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

Method test_unzip_zipfile

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

Source from the content-addressed store, hash-verified

1886 @unittest.skipUnless(shutil.which('unzip'),
1887 'Need the unzip command to run')
1888 def test_unzip_zipfile(self):
1889 root_dir, base_dir = self._create_files()
1890 base_name = os.path.join(self.mkdtemp(), 'archive')
1891 with no_chdir:
1892 archive = make_archive(base_name, 'zip', root_dir, base_dir)
1893
1894 # check if ZIP file was created
1895 self.assertEqual(archive, base_name + '.zip')
1896 self.assertTrue(os.path.isfile(archive))
1897
1898 # now check the ZIP file using `unzip -t`
1899 zip_cmd = ['unzip', '-t', archive]
1900 with os_helper.change_cwd(root_dir):
1901 try:
1902 subprocess.check_output(zip_cmd, stderr=subprocess.STDOUT)
1903 except subprocess.CalledProcessError as exc:
1904 details = exc.output.decode(errors="replace")
1905 if any(message in details for message in [
1906 'unrecognized option: t', # BusyBox
1907 'invalid option -- t', # Android
1908 ]):
1909 self.skipTest("unzip doesn't support -t")
1910 msg = "{}\n\n**Unzip Output**\n{}"
1911 self.fail(msg.format(exc, details))
1912
1913 def test_make_archive(self):
1914 tmpdir = self.mkdtemp()

Callers

nothing calls this directly

Calls 13

_create_filesMethod · 0.95
make_archiveFunction · 0.90
mkdtempMethod · 0.80
assertTrueMethod · 0.80
skipTestMethod · 0.80
anyFunction · 0.50
joinMethod · 0.45
assertEqualMethod · 0.45
isfileMethod · 0.45
check_outputMethod · 0.45
decodeMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected