summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zlib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-11 23:38:15 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-11 23:38:15 (GMT)
commitbbff8cf035c2ca490efe7135b004cfbf8340b767 (patch)
tree273bc111cd2fd26fb8dbb9ad9e439acb91c12b54 /Lib/test/test_zlib.py
parent9c578a8dba6dcfc11aa0e9d04687a191ebdf4048 (diff)
downloadcpython-bbff8cf035c2ca490efe7135b004cfbf8340b767.zip
cpython-bbff8cf035c2ca490efe7135b004cfbf8340b767.tar.gz
cpython-bbff8cf035c2ca490efe7135b004cfbf8340b767.tar.bz2
Merged revisions 81096 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81096 | antoine.pitrou | 2010-05-12 01:36:40 +0200 (mer., 12 mai 2010) | 11 lines Merged revisions 81094 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81094 | antoine.pitrou | 2010-05-12 01:32:31 +0200 (mer., 12 mai 2010) | 6 lines Issue #8672: Add a zlib test ensuring that an incomplete stream can be handled by a decompressor object without errors (it returns incomplete uncompressed data). ........ ................
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r--Lib/test/test_zlib.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 3a5bd30..0c259cc 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -379,6 +379,19 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
dco = zlib.decompressobj()
self.assertEqual(dco.flush(), b"") # Returns nothing
+ def test_decompress_incomplete_stream(self):
+ # This is 'foo', deflated
+ x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
+ # For the record
+ self.assertEqual(zlib.decompress(x), b'foo')
+ self.assertRaises(zlib.error, zlib.decompress, x[:-5])
+ # Omitting the stream end works with decompressor objects
+ # (see issue #8672).
+ dco = zlib.decompressobj()
+ y = dco.decompress(x[:-5])
+ y += dco.flush()
+ self.assertEqual(y, b'foo')
+
if hasattr(zlib.compressobj(), "copy"):
def test_compresscopy(self):
# Test copying a compression object