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