diff options
author | Zhiming Wang <zmwangx@gmail.com> | 2017-09-29 17:31:52 (GMT) |
---|---|---|
committer | Paul Moore <p.f.moore@gmail.com> | 2017-09-29 17:31:52 (GMT) |
commit | d87b105ca794addf92addb28293c92a7ef4141e1 (patch) | |
tree | 65d69e9473d93bb612d4c3fedbfb714626d402f5 /Lib/test | |
parent | 6fb0e4a6d085ffa4e4a6daaea042a1cc517fa8bc (diff) | |
download | cpython-d87b105ca794addf92addb28293c92a7ef4141e1.zip cpython-d87b105ca794addf92addb28293c92a7ef4141e1.tar.gz cpython-d87b105ca794addf92addb28293c92a7ef4141e1.tar.bz2 |
bpo-31638: Add compression support to zipapp (GH-3819)
Add optional argument `compressed` to `zipapp.create_archive`, and add
option `--compress` to the command line interface of `zipapp`.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_zipapp.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_zipapp.py b/Lib/test/test_zipapp.py index 56cf37c..3602b99 100644 --- a/Lib/test/test_zipapp.py +++ b/Lib/test/test_zipapp.py @@ -100,6 +100,20 @@ class ZipAppTest(unittest.TestCase): expected_target = self.tmpdir / 'source.pyz' self.assertTrue(expected_target.is_file()) + def test_create_archive_with_compression(self): + # Test packing a directory into a compressed archive. + source = self.tmpdir / 'source' + source.mkdir() + (source / '__main__.py').touch() + (source / 'test.py').touch() + target = self.tmpdir / 'source.pyz' + + zipapp.create_archive(source, target, compressed=True) + with zipfile.ZipFile(target, 'r') as z: + for name in ('__main__.py', 'test.py'): + self.assertEqual(z.getinfo(name).compress_type, + zipfile.ZIP_DEFLATED) + def test_no_main(self): # Test that packing a directory with no __main__.py fails. source = self.tmpdir / 'source' |