#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 ee1eecb..652274f 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -703,6 +703,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 test_closed_zip_raises_RuntimeError(self):
# Verify that testzip() doesn't swallow inappropriate exceptions.
data = StringIO()