summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-20 19:57:40 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-20 19:57:40 (GMT)
commit9b7a1a1af6de71411102e2b95ee3f654cb0cc700 (patch)
tree6640cddb13dc6c0da47373049956699fd3bdce06 /Lib/test/test_zipfile.py
parent7e52705ee362001a8761461e9c4d49e3873568e0 (diff)
downloadcpython-9b7a1a1af6de71411102e2b95ee3f654cb0cc700.zip
cpython-9b7a1a1af6de71411102e2b95ee3f654cb0cc700.tar.gz
cpython-9b7a1a1af6de71411102e2b95ee3f654cb0cc700.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/test_zipfile.py')
-rw-r--r--Lib/test/test_zipfile.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index a561d59..12a0f71 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -844,7 +844,9 @@ class OtherTests(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 self.assertWarns(UserWarning):
+ zipfp.writestr("name", "bar")
+ self.assertEqual(zipfp.namelist(), ["name"] * 2)
with zipfile.ZipFile(TESTFN2, "r") as zipfp:
infos = zipfp.infolist()
@@ -1150,7 +1152,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 + b'oops'
+ with self.assertWarns(UserWarning):
+ zipf.comment = comment2 + b'oops'
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
self.assertEqual(zipfr.comment, comment2)