summaryrefslogtreecommitdiff
path: root/Lib/test/test_zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-20 21:59:33 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-20 21:59:33 +0200
commitc46d1faa4a4b483f2b241bfbe932824d54f2f026 (patch)
tree0dd3bdb38e220d2cf15dcad1a139a4f7216192d6 /Lib/test/test_zipfile.py
parentab0ac27d24076a2a09e3d8de97055a2fc978709f (diff)
parent9b7a1a1af6de71411102e2b95ee3f654cb0cc700 (diff)
downloadcpython-git-c46d1faa4a4b483f2b241bfbe932824d54f2f026.tar.gz
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.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 33602cff55..1bef5750a1 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -646,7 +646,7 @@ class PyZipFileTests(unittest.TestCase):
self.assertTrue('SyntaxError' not in reportStr)
# then check that the filter works on individual files
- with captured_stdout() as reportSIO:
+ with captured_stdout() as reportSIO, self.assertWarns(UserWarning):
zipfp.writepy(packagedir, filterfunc=lambda fn:
'bad' not in fn)
reportStr = reportSIO.getvalue()
@@ -896,7 +896,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()
@@ -1213,7 +1215,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)