summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-22 12:56:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-22 12:56:22 (GMT)
commit37c02acb6fddd3d745646736d8d8a2040b69c084 (patch)
tree5ab229cf117ab01608ad606e71885d7bca42abe3 /Lib/test/test_shutil.py
parenta0ae9ff00653f461f44a5b195654cc9dcd0fef92 (diff)
downloadcpython-37c02acb6fddd3d745646736d8d8a2040b69c084.zip
cpython-37c02acb6fddd3d745646736d8d8a2040b69c084.tar.gz
cpython-37c02acb6fddd3d745646736d8d8a2040b69c084.tar.bz2
Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
entries. Patch by Dingyuan Wang.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 71317b3..c85f25e 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -511,6 +511,29 @@ class TestShutil(unittest.TestCase):
names2 = zf.namelist()
self.assertEqual(sorted(names), sorted(names2))
+ @unittest.skipUnless(zlib, "Requires zlib")
+ @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
+ @unittest.skipUnless(find_executable('unzip'),
+ 'Need the unzip command to run')
+ def test_unzip_zipfile(self):
+ root_dir, base_dir = self._create_files()
+ base_name = os.path.join(self.mkdtemp(), 'archive')
+ archive = make_archive(base_name, 'zip', root_dir, base_dir)
+
+ # check if ZIP file was created
+ self.assertEqual(archive, base_name + '.zip')
+ self.assertTrue(os.path.isfile(archive))
+
+ # now check the ZIP file using `unzip -t`
+ zip_cmd = ['unzip', '-t', archive]
+ with support.change_cwd(root_dir):
+ try:
+ subprocess.check_output(zip_cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as exc:
+ details = exc.output
+ msg = "{}\n\n**Unzip Output**\n{}"
+ self.fail(msg.format(exc, details))
+
def test_make_archive(self):
tmpdir = self.mkdtemp()
base_name = os.path.join(tmpdir, 'archive')