MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_odd_flush

Method test_odd_flush

Lib/test/test_zlib.py:522–541  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

520 @unittest.skipUnless(hasattr(zlib, 'Z_SYNC_FLUSH'),
521 'requires zlib.Z_SYNC_FLUSH')
522 def test_odd_flush(self):
523 # Test for odd flushing bugs noted in 2.0, and hopefully fixed in 2.1
524 import random
525 # Testing on 17K of "random" data
526
527 # Create compressor and decompressor objects
528 co = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
529 dco = zlib.decompressobj()
530
531 # Try 17K of data
532 # generate random data stream
533 data = random.randbytes(17 * 1024)
534
535 # compress, sync-flush, and decompress
536 first = co.compress(data)
537 second = co.flush(zlib.Z_SYNC_FLUSH)
538 expanded = dco.decompress(first + second)
539
540 # if decompressed data is different from the input data, choke.
541 self.assertEqual(expanded, data, "17K random source doesn't match")
542
543 def test_empty_flush(self):
544 # Test that calling .flush() on unused objects works.

Callers

nothing calls this directly

Calls 5

randbytesMethod · 0.45
compressMethod · 0.45
flushMethod · 0.45
decompressMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected