[Python-checkins] CVS: python/dist/src/Lib/test test_zlib.py,1.11,1.12

A.M. Kuchling akuchling@users.sourceforge.net
Tue, 20 Feb 2001 18:17:03 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv31901

Modified Files:
	test_zlib.py 
Log Message:
Add test case from bug #124981: zlib decompress of sync-flushed data
    fails


Index: test_zlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zlib.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** test_zlib.py	2001/02/14 17:46:20	1.11
--- test_zlib.py	2001/02/21 02:17:01	1.12
***************
*** 1,3 ****
--- 1,4 ----
  import zlib
+ from test_support import TestFailed
  import sys
  import imp
***************
*** 88,91 ****
--- 89,117 ----
              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():