diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-20 19:57:09 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-20 19:57:09 (GMT) |
commit | 49259359eebaead3973816731fcb98bff0673900 (patch) | |
tree | c259202111556dca2bcc06ca9e1782f2ea8cbdb4 /Lib/test | |
parent | ad715d9e97b3a3a01653c27fee4555f605164c4a (diff) | |
download | cpython-49259359eebaead3973816731fcb98bff0673900.zip cpython-49259359eebaead3973816731fcb98bff0673900.tar.gz cpython-49259359eebaead3973816731fcb98bff0673900.tar.bz2 |
Issue #20262: Warnings are raised now when duplicate names are added in the
ZIP file or too long ZIP file comment is truncated.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_zipfile.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 9e3a28b..97a71e6 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -19,7 +19,7 @@ from random import randint, random from unittest import skipUnless from test.test_support import TESTFN, TESTFN_UNICODE, TESTFN_ENCODING, \ - run_unittest, findfile, unlink + run_unittest, findfile, unlink, check_warnings try: TESTFN_UNICODE.encode(TESTFN_ENCODING) except (UnicodeError, TypeError): @@ -148,7 +148,9 @@ class TestsWithSourceFile(unittest.TestCase): # Create the ZIP archive with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: zipfp.writestr("name", "foo") - zipfp.writestr("name", "bar") + with check_warnings(('', UserWarning)): + zipfp.writestr("name", "bar") + self.assertEqual(zipfp.namelist(), ["name"] * 2) with zipfile.ZipFile(TESTFN2, "r") as zipfp: infos = zipfp.infolist() @@ -1035,7 +1037,8 @@ class OtherTests(unittest.TestCase): # check a comment that is too long is truncated with zipfile.ZipFile(TESTFN, mode="w") as zipf: - zipf.comment = comment2 + 'oops' + with check_warnings(('', UserWarning)): + zipf.comment = comment2 + 'oops' zipf.writestr("foo.txt", "O, for a Muse of Fire!") with zipfile.ZipFile(TESTFN, mode="r") as zipf: self.assertEqual(zipf.comment, comment2) |