Merged revisions 74245 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74245 | amaury.forgeotdarc | 2009-07-28 18:15:30 -0400 (Tue, 28 Jul 2009) | 3 lines
#6511: ZipFile will now raise BadZipfile when opening an empty or tiny file,
like it does for larger invalid files.
........
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 1fed79a..a2c3a2c 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -664,6 +664,16 @@
# quickly.
self.assertRaises(IOError, zipfile.ZipFile, TESTFN)
+ def test_empty_file_raises_BadZipFile(self):
+ f = open(TESTFN, 'w')
+ f.close()
+ self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
+
+ f = open(TESTFN, 'w')
+ f.write("short file")
+ f.close()
+ self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
+
def testClosedZipRaisesRuntimeError(self):
# Verify that testzip() doesn't swallow inappropriate exceptions.
data = StringIO()