]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added simple test for the flush() method of compression objects, trying the
authorAndrew M. Kuchling <amk@amk.ca>
Mon, 22 Mar 1999 19:23:17 +0000 (19:23 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Mon, 22 Mar 1999 19:23:17 +0000 (19:23 +0000)
    different flush values Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH.

Lib/test/test_zlib.py

index 047e9858842ff260b57da5bdcc776dc4f41db09a..719b0e7a0dd68000ab866193b4d4061b0d4de074 100644 (file)
@@ -76,6 +76,19 @@ if decomp2 != buf:
 else:
     print "decompressobj with init options succeeded"
 
+# Test flush() with the various options, using all the different levels
+# in order to provide more variations.
+for sync in [zlib.Z_NO_FLUSH, zlib.Z_SYNC_FLUSH, zlib.Z_FULL_FLUSH]:
+    for level in range(10):
+       obj = zlib.compressobj( level )
+       d = obj.compress( buf[:3000] )
+       d = d + obj.flush( sync )
+       d = d + obj.compress( buf[3000:] )
+       d = d + obj.flush()
+       if zlib.decompress(d) != buf:
+           print "Decompress failed: flush mode=%i, level=%i" % (sync,level)
+       del obj
+
 def ignore():
     """An empty function with a big string.