mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Added simple test for the flush() method of compression objects, trying the
different flush values Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH.
This commit is contained in:
parent
f247d75507
commit
dca7e00fd5
1 changed files with 13 additions and 0 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue