diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-06-09 19:52:31 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-06-09 19:52:31 (GMT) |
commit | 51fcb811e3169661d2995b1e6de6d1b46a7284c3 (patch) | |
tree | 42ecf975c86f72755444967f1c94e542282e54ae /Lib/test/test_zipfile.py | |
parent | 0a9f16b62738dd5ab14907a870a18f8b81a2058a (diff) | |
parent | 4fbb9dbd3421fca6d4c289d996ef035da0cef330 (diff) | |
download | cpython-51fcb811e3169661d2995b1e6de6d1b46a7284c3.zip cpython-51fcb811e3169661d2995b1e6de6d1b46a7284c3.tar.gz cpython-51fcb811e3169661d2995b1e6de6d1b46a7284c3.tar.bz2 |
Merge #10694: zipfile now ignores garbage at the end of a zipfile.
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r-- | Lib/test/test_zipfile.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 9663715..4dcb690 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -345,6 +345,24 @@ class TestsWithSourceFile(unittest.TestCase): with zipfile.ZipFile(f, "r") as zipfp: self.assertEqual(zipfp.namelist(), [TESTFN]) + def test_ignores_newline_at_end(self): + with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: + zipfp.write(TESTFN, TESTFN) + with open(TESTFN2, 'a') as f: + f.write("\r\n\00\00\00") + with zipfile.ZipFile(TESTFN2, "r") as zipfp: + self.assertIsInstance(zipfp, zipfile.ZipFile) + + def test_ignores_stuff_appended_past_comments(self): + with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: + zipfp.comment = b"this is a comment" + zipfp.write(TESTFN, TESTFN) + with open(TESTFN2, 'a') as f: + f.write("abcdef\r\n") + with zipfile.ZipFile(TESTFN2, "r") as zipfp: + self.assertIsInstance(zipfp, zipfile.ZipFile) + self.assertEqual(zipfp.comment, b"this is a comment") + def test_write_default_name(self): """Check that calling ZipFile.write without arcname specified produces the expected result.""" |