summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-09-27 19:11:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-09-27 19:11:57 (GMT)
commitd2c07a58affecc3fb049652ee7a435c382e3a4d0 (patch)
tree07a07c8b2115e859192c8b0d18eb116e71bcb3ed /Lib/test/test_zipfile.py
parent1f09c663add7edc6af0093d1eb3eca02bd0864b9 (diff)
downloadcpython-d2c07a58affecc3fb049652ee7a435c382e3a4d0.zip
cpython-d2c07a58affecc3fb049652ee7a435c382e3a4d0.tar.gz
cpython-d2c07a58affecc3fb049652ee7a435c382e3a4d0.tar.bz2
Issue #19053: ZipExtFile.read1() with non-zero argument no more returns empty
bytes until end of data.
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r--Lib/test/test_zipfile.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index fb866d8..ad0c0b7 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -158,6 +158,45 @@ class AbstractTestsWithSourceFile:
for f in get_files(self):
self.zip_random_open_test(f, self.compression)
+ def zip_read1_test(self, f, compression):
+ self.make_test_archive(f, compression)
+
+ # Read the ZIP archive
+ with zipfile.ZipFile(f, "r") as zipfp, \
+ zipfp.open(TESTFN) as zipopen:
+ zipdata = []
+ while True:
+ read_data = zipopen.read1(-1)
+ if not read_data:
+ break
+ zipdata.append(read_data)
+
+ self.assertEqual(b''.join(zipdata), self.data)
+
+ def test_read1(self):
+ for f in get_files(self):
+ self.zip_read1_test(f, self.compression)
+
+ def zip_read1_10_test(self, f, compression):
+ self.make_test_archive(f, compression)
+
+ # Read the ZIP archive
+ with zipfile.ZipFile(f, "r") as zipfp, \
+ zipfp.open(TESTFN) as zipopen:
+ zipdata = []
+ while True:
+ read_data = zipopen.read1(10)
+ self.assertLessEqual(len(read_data), 10)
+ if not read_data:
+ break
+ zipdata.append(read_data)
+
+ self.assertEqual(b''.join(zipdata), self.data)
+
+ def test_read1_10(self):
+ for f in get_files(self):
+ self.zip_read1_10_test(f, self.compression)
+
def zip_readline_read_test(self, f, compression):
self.make_test_archive(f, compression)