• Home
  • Raw
  • Download

Lines Matching full:zlib

9 zlib = support.import_module('zlib')  variable
12 hasattr(zlib.compressobj(), "copy"),
15 hasattr(zlib.decompressobj(), "copy"),
27 self.assertEqual(zlib.ZLIB_RUNTIME_VERSION[0], zlib.ZLIB_VERSION[0])
33 self.assertEqual(zlib.crc32(b""), zlib.crc32(b"", 0))
34 self.assertTrue(zlib.crc32(b"abc", 0xffffffff))
37 self.assertEqual(zlib.crc32(b"", 0), 0)
38 self.assertEqual(zlib.crc32(b"", 1), 1)
39 self.assertEqual(zlib.crc32(b"", 432), 432)
42 self.assertEqual(zlib.adler32(b""), zlib.adler32(b"", 1))
43 self.assertTrue(zlib.adler32(b"abc", 0xffffffff))
46 self.assertEqual(zlib.adler32(b"", 0), 0)
47 self.assertEqual(zlib.adler32(b"", 1), 1)
48 self.assertEqual(zlib.adler32(b"", 432), 432)
51 self.assertEqual(zlib.crc32(b"penguin", 0), 0x0e5c1a120)
52 self.assertEqual(zlib.crc32(b"penguin", 1), 0x43b6aa94)
53 self.assertEqual(zlib.adler32(b"penguin", 0), 0x0bcf02f6)
54 self.assertEqual(zlib.adler32(b"penguin", 1), 0x0bd602f7)
56 self.assertEqual(zlib.crc32(b"penguin"), zlib.crc32(b"penguin", 0))
57 self.assertEqual(zlib.adler32(b"penguin"),zlib.adler32(b"penguin",1))
62 self.assertEqual(zlib.crc32(foo), 2486878355)
63 self.assertEqual(zlib.crc32(b'spam'), 1138425661)
64 self.assertEqual(zlib.adler32(foo+foo), 3573550353)
65 self.assertEqual(zlib.adler32(b'spam'), 72286642)
71 self.assertEqual(zlib.crc32(foo), crc)
72 self.assertEqual(binascii.crc32(b'spam'), zlib.crc32(b'spam'))
81 self.assertEqual(zlib.crc32(data), 1044521549)
82 self.assertEqual(zlib.adler32(data), 2256789997)
89 # (but -1 is Z_DEFAULT_COMPRESSION and apparently the zlib
91 self.assertRaises(zlib.error, zlib.compress, b'ERROR', 10)
94 self.assertRaises(TypeError, zlib.adler32)
95 self.assertRaises(TypeError, zlib.crc32)
96 self.assertRaises(TypeError, zlib.compress)
97 self.assertRaises(TypeError, zlib.decompress)
99 self.assertRaises(TypeError, zlib.adler32, arg)
100 self.assertRaises(TypeError, zlib.crc32, arg)
101 self.assertRaises(TypeError, zlib.compress, arg)
102 self.assertRaises(TypeError, zlib.decompress, arg)
106 self.assertRaises(ValueError, zlib.compressobj, 1, zlib.DEFLATED, 0)
109 zlib.compressobj, 1, zlib.DEFLATED, zlib.MAX_WBITS + 1)
113 self.assertRaises(ValueError, zlib.decompressobj, -1)
117 self.assertRaises(ValueError, zlib.decompressobj().flush, 0)
118 self.assertRaises(ValueError, zlib.decompressobj().flush, -1)
123 zlib.decompress(b'', 15, sys.maxsize + 1)
125 zlib.decompressobj().decompress(b'', sys.maxsize + 1)
127 zlib.decompressobj().flush(sys.maxsize + 1)
134 # The assumption is that zlib's memory is not big enough to exploit
148 compressed = zlib.compress(data, 1)
164 x = zlib.compress(HAMLET_SCENE)
165 self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
168 x = zlib.compress(HAMLET_SCENE, level=3)
169 self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
171 zlib.compress(data=HAMLET_SCENE, level=3)
172 self.assertEqual(zlib.decompress(x,
173 wbits=zlib.MAX_WBITS,
174 bufsize=zlib.DEF_BUF_SIZE),
180 x = zlib.compress(data)
181 self.assertEqual(zlib.compress(bytearray(data)), x)
183 self.assertEqual(zlib.decompress(ob), data)
187 x = zlib.compress(HAMLET_SCENE)
188 self.assertRaisesRegex(zlib.error,
190 zlib.decompress, x[:-1])
196 compress = lambda s: zlib.compress(s, 1)
201 self.check_big_decompress_buffer(size, zlib.decompress)
207 compressed = zlib.compress(data, 1)
208 self.assertEqual(zlib.decompress(compressed, 15, size), data)
212 compressed = zlib.compress(data, 1)
213 self.assertEqual(zlib.decompress(compressed, 15, CustomInt()), data)
220 comp = zlib.compress(data, 0)
221 self.assertEqual(zlib.decompress(comp), data)
231 datazip = zlib.compress(datasrc)
234 co = zlib.compressobj()
237 self.assertRaises(zlib.error, co.flush) # second flush should not work
240 dco = zlib.decompressobj()
249 method = zlib.DEFLATED
252 strategy = zlib.Z_FILTERED
253 co = zlib.compressobj(level=level,
259 do = zlib.decompressobj(wbits=wbits, zdict=b"")
263 do.decompress(data=zlib.compress(HAMLET_SCENE))
271 method = zlib.DEFLATED
274 strategy = zlib.Z_FILTERED
275 co = zlib.compressobj(level, method, wbits, memLevel, strategy)
278 dco = zlib.decompressobj(wbits)
286 co = zlib.compressobj()
293 dco = zlib.decompressobj()
302 co = zlib.compressobj()
309 decombuf = zlib.decompress(combuf)
315 dco = zlib.decompressobj()
347 co = zlib.compressobj()
353 self.assertEqual(data, zlib.decompress(combuf),
356 dco = zlib.decompressobj()
372 co = zlib.compressobj()
378 self.assertEqual(data, zlib.decompress(combuf),
381 dco = zlib.decompressobj()
406 dco = zlib.decompressobj()
411 # Sizes up to sys.maxsize should be accepted, although zlib is
414 self.assertGreater(len(data), zlib.DEF_BUF_SIZE)
415 compressed = zlib.compress(data, 1)
416 dco = zlib.decompressobj()
421 compressed = zlib.compress(data, 1)
422 dco = zlib.decompressobj()
429 dco = zlib.decompressobj()
440 ver = tuple(int(v) for v in zlib.ZLIB_RUNTIME_VERSION.split('.'))
445 sync_opt = [getattr(zlib, opt) for opt in sync_opt
446 if hasattr(zlib, opt)]
452 obj = zlib.compressobj( level )
461 self.assertEqual(zlib.decompress(b''.join([a,b,c,d])),
466 @unittest.skipUnless(hasattr(zlib, 'Z_SYNC_FLUSH'),
467 'requires zlib.Z_SYNC_FLUSH')
474 co = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
475 dco = zlib.decompressobj()
494 second = co.flush(zlib.Z_SYNC_FLUSH)
505 co = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
506 self.assertTrue(co.flush()) # Returns a zlib header
507 dco = zlib.decompressobj()
517 co = zlib.compressobj(zdict=zdict)
520 dco = zlib.decompressobj(zdict=zdict)
523 dco = zlib.decompressobj()
524 self.assertRaises(zlib.error, dco.decompress, cd)
529 co = zlib.compressobj(zdict=HAMLET_SCENE)
530 do = zlib.decompressobj(zdict=HAMLET_SCENE)
532 d0 = co.compress(piece) + co.flush(zlib.Z_SYNC_FLUSH)
533 d1 = co.compress(piece[100:]) + co.flush(zlib.Z_SYNC_FLUSH)
534 d2 = co.compress(piece[:-100]) + co.flush(zlib.Z_SYNC_FLUSH)
543 self.assertEqual(zlib.decompress(x), b'foo')
544 self.assertRaises(zlib.error, zlib.decompress, x[:-5])
547 dco = zlib.decompressobj()
554 dco = zlib.decompressobj()
565 dco = zlib.decompressobj()
577 y = zlib.compress(source)
581 dco = zlib.decompressobj()
601 co = zlib.compressobj(wbits=-zlib.MAX_WBITS, zdict=zdict)
603 dco = zlib.decompressobj(wbits=-zlib.MAX_WBITS, zdict=zdict)
612 data = zlib.compress(input1)
613 dco = zlib.decompressobj()
616 data = zlib.compress(input2)
623 data = zlib.compress(input, 1)
624 dco = zlib.decompressobj()
630 data = zlib.compress(input, 1)
631 dco = zlib.decompressobj()
640 c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
655 self.assertEqual(zlib.decompress(s0),data0+data0)
656 self.assertEqual(zlib.decompress(s1),data0+data1)
661 c = zlib.compressobj()
670 comp = zlib.compress(data)
674 d0 = zlib.decompressobj()
693 data = zlib.compress(HAMLET_SCENE)
694 d = zlib.decompressobj()
702 pickle.dumps(zlib.compressobj(zlib.Z_BEST_COMPRESSION), proto)
707 pickle.dumps(zlib.decompressobj(), proto)
713 c = zlib.compressobj(1)
719 d = zlib.decompressobj()
727 co = zlib.compressobj(0)
728 do = zlib.decompressobj()
741 comp = zlib.compress(data) + unused
742 do = zlib.decompressobj()
754 do = zlib.decompressobj()
756 comp = zlib.compress(data, 0)
764 # wbits=0 only supported since zlib v1.2.3.5
767 v = zlib.ZLIB_RUNTIME_VERSION.split('-', 1)[0].split('.')
776 co = zlib.compressobj(level=1, wbits=15)
778 self.assertEqual(zlib.decompress(zlib15, 15), HAMLET_SCENE)
780 self.assertEqual(zlib.decompress(zlib15, 0), HAMLET_SCENE)
781 self.assertEqual(zlib.decompress(zlib15, 32 + 15), HAMLET_SCENE)
782 with self.assertRaisesRegex(zlib.error, 'invalid window size'):
783 zlib.decompress(zlib15, 14)
784 dco = zlib.decompressobj(wbits=32 + 15)
786 dco = zlib.decompressobj(wbits=14)
787 with self.assertRaisesRegex(zlib.error, 'invalid window size'):
790 co = zlib.compressobj(level=1, wbits=9)
792 self.assertEqual(zlib.decompress(zlib9, 9), HAMLET_SCENE)
793 self.assertEqual(zlib.decompress(zlib9, 15), HAMLET_SCENE)
795 self.assertEqual(zlib.decompress(zlib9, 0), HAMLET_SCENE)
796 self.assertEqual(zlib.decompress(zlib9, 32 + 9), HAMLET_SCENE)
797 dco = zlib.decompressobj(wbits=32 + 9)
800 co = zlib.compressobj(level=1, wbits=-15)
802 self.assertEqual(zlib.decompress(deflate15, -15), HAMLET_SCENE)
803 dco = zlib.decompressobj(wbits=-15)
806 co = zlib.compressobj(level=1, wbits=-9)
808 self.assertEqual(zlib.decompress(deflate9, -9), HAMLET_SCENE)
809 self.assertEqual(zlib.decompress(deflate9, -15), HAMLET_SCENE)
810 dco = zlib.decompressobj(wbits=-9)
813 co = zlib.compressobj(level=1, wbits=16 + 15)
815 self.assertEqual(zlib.decompress(gzip, 16 + 15), HAMLET_SCENE)
816 self.assertEqual(zlib.decompress(gzip, 32 + 15), HAMLET_SCENE)
817 dco = zlib.decompressobj(32 + 15)