diff options
author | Zackery Spytz <zspytz@gmail.com> | 2018-09-25 19:15:47 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2018-09-25 19:15:47 (GMT) |
commit | 5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc (patch) | |
tree | 4e466db8516df40b4bd1d902175d8de26e724f3e /Lib/test/test_zipimport.py | |
parent | 996859a90df51f84eab47351702cb59c6db4428a (diff) | |
download | cpython-5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc.zip cpython-5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc.tar.gz cpython-5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc.tar.bz2 |
bpo-5950: Support reading zips with comments in zipimport (#9548)
* bpo-5950: Support reading zips with comments in zipimport
Diffstat (limited to 'Lib/test/test_zipimport.py')
-rw-r--r-- | Lib/test/test_zipimport.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 63e5672..e98b090 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -116,6 +116,9 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression z.writestr(zinfo, data) + comment = kw.get("comment", None) + if comment is not None: + z.comment = comment stuff = kw.get("stuff", None) if stuff is not None: @@ -665,6 +668,18 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): with self.assertRaises(TypeError): zipimport.zipimporter(memoryview(os.fsencode(filename))) + def testComment(self): + files = {TESTMOD + ".py": (NOW, test_src)} + self.doTest(".py", files, TESTMOD, comment=b"comment") + + def testBeginningCruftAndComment(self): + files = {TESTMOD + ".py": (NOW, test_src)} + self.doTest(".py", files, TESTMOD, stuff=b"cruft" * 64, comment=b"hi") + + def testLargestPossibleComment(self): + files = {TESTMOD + ".py": (NOW, test_src)} + self.doTest(".py", files, TESTMOD, comment=b"c" * ((1 << 16) - 1)) + @support.requires_zlib class CompressedZipImportTestCase(UncompressedZipImportTestCase): |