diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2001-02-21 02:17:01 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2001-02-21 02:17:01 (GMT) |
commit | 9a0f98e0a140caed40006f9c9990d028ffa9ffd1 (patch) | |
tree | 7edefdb6055bda152946558d77af721d3623265b /Lib | |
parent | 9aff4a2ad003dcc98c59fc2788e5f9146f8a53be (diff) | |
download | cpython-9a0f98e0a140caed40006f9c9990d028ffa9ffd1.zip cpython-9a0f98e0a140caed40006f9c9990d028ffa9ffd1.tar.gz cpython-9a0f98e0a140caed40006f9c9990d028ffa9ffd1.tar.bz2 |
Add test case from bug #124981: zlib decompress of sync-flushed data
fails
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/output/test_zlib | 1 | ||||
-rw-r--r-- | Lib/test/test_zlib.py | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/output/test_zlib b/Lib/test/output/test_zlib index 6995c11..61c33cf 100644 --- a/Lib/test/output/test_zlib +++ b/Lib/test/output/test_zlib @@ -8,3 +8,4 @@ normal compression/decompression succeeded compress/decompression obj succeeded decompress with init options succeeded decompressobj with init options succeeded +Testing on 17K of random data diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 70da76d..3b78399 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -1,4 +1,5 @@ import zlib +from test_support import TestFailed import sys import imp @@ -88,6 +89,31 @@ for sync in [zlib.Z_NO_FLUSH, zlib.Z_SYNC_FLUSH, zlib.Z_FULL_FLUSH]: print "Decompress failed: flush mode=%i, level=%i" % (sync,level) del obj +# Test for the odd flushing bugs noted in 2.0, and hopefully fixed in 2.1 + +import random +random.seed(1) + +print 'Testing on 17K of random data' + +# Create compressor and decompressor objects +c=zlib.compressobj(9) +d=zlib.decompressobj() + +# Try 17K of data +# generate random data stream +a="" +for i in range(17*1024): + a=a+chr(random.randint(0,255)) + +# compress, sync-flush, and decompress +t = d.decompress( c.compress(a)+c.flush(zlib.Z_SYNC_FLUSH) ) + +# if decompressed data is different from the input data, choke. +if len(t) != len(a): + print len(a),len(t),len(d.unused_data) + raise TestFailed, "output of 17K doesn't match" + def ignore(): """An empty function with a big string. |