summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-05-20 08:25:48 (GMT)
committerGeorg Brandl <georg@python.org>2008-05-20 08:25:48 (GMT)
commit112aa5032985925608844d7421e12703afd6ce41 (patch)
treeb7e26da27c90471192c42afea278b8b9f59ef9f3 /Lib/test
parent4dd019fde36b53b30e69a2ce9cee3f2f9f25c2a6 (diff)
downloadcpython-112aa5032985925608844d7421e12703afd6ce41.zip
cpython-112aa5032985925608844d7421e12703afd6ce41.tar.gz
cpython-112aa5032985925608844d7421e12703afd6ce41.tar.bz2
Patch #1775025: allow opening zipfile members via ZipInfo instances.
Patch by Graham Horler.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_zipfile.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index c83622a..4bc2104 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -132,6 +132,25 @@ class TestsWithSourceFile(unittest.TestCase):
for f in (TESTFN2, TemporaryFile(), StringIO()):
self.zipOpenTest(f, zipfile.ZIP_STORED)
+ def testOpenViaZipInfo(self):
+ # Create the ZIP archive
+ zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED)
+ zipfp.writestr("name", "foo")
+ zipfp.writestr("name", "bar")
+ zipfp.close()
+
+ zipfp = zipfile.ZipFile(TESTFN2, "r")
+ infos = zipfp.infolist()
+ data = ""
+ for info in infos:
+ data += zipfp.open(info).read()
+ self.assert_(data == "foobar" or data == "barfoo")
+ data = ""
+ for info in infos:
+ data += zipfp.read(info)
+ self.assert_(data == "foobar" or data == "barfoo")
+ zipfp.close()
+
def zipRandomOpenTest(self, f, compression):
self.makeTestArchive(f, compression)