2020 'requires Decompress.copy()' )
2121
2222
23- # def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
24- # # Register "1.2.3" as "1.2.3.0"
25- # # or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
26- # v = zlib_version.split('-', 1)[0].split('.')
27- # if len(v) < 4:
28- # v.append('0')
29- # elif not v[-1].isnumeric():
30- # v[-1] = '0'
31- # return tuple(map(int, v))
32- #
33- #
34- # ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
23+ def _zlib_runtime_version_tuple (zlib_version = zlib .ZLIB_RUNTIME_VERSION ):
24+ # Register "1.2.3" as "1.2.3.0"
25+ # or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
26+ v = zlib_version .split ('-' , 1 )[0 ].split ('.' )
27+ if len (v ) < 4 :
28+ v .append ('0' )
29+ elif not v [- 1 ].isnumeric ():
30+ v [- 1 ] = '0'
31+ return tuple (map (int , v ))
32+
33+
34+ ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple ()
3535
3636
3737# bpo-46623: When a hardware accelerator is used (currently only on s390x),
6666
6767class VersionTestCase (unittest .TestCase ):
6868
69- # TODO: RUSTPYTHON
70- @unittest .expectedFailure
7169 def test_library_version (self ):
7270 # Test that the major version of the actual library in use matches the
7371 # major version that we were compiled against. We can't guarantee that
@@ -282,8 +280,6 @@ def test_64bit_compress(self, size):
282280
283281
284282class CompressObjectTestCase (BaseCompressTestCase , unittest .TestCase ):
285- # TODO: RUSTPYTHON
286- @unittest .expectedFailure
287283 # Test compression object
288284 def test_pair (self ):
289285 # straightforward compress/decompress objects
@@ -307,8 +303,6 @@ def test_pair(self):
307303 self .assertIsInstance (dco .unconsumed_tail , bytes )
308304 self .assertIsInstance (dco .unused_data , bytes )
309305
310- # TODO: RUSTPYTHON
311- @unittest .expectedFailure
312306 def test_keywords (self ):
313307 level = 2
314308 method = zlib .DEFLATED
@@ -466,8 +460,6 @@ def test_decompressmaxlen(self, flush=False):
466460 def test_decompressmaxlenflush (self ):
467461 self .test_decompressmaxlen (flush = True )
468462
469- # TODO: RUSTPYTHON
470- @unittest .expectedFailure
471463 def test_maxlenmisc (self ):
472464 # Misc tests of max_length
473465 dco = zlib .decompressobj ()
@@ -498,7 +490,7 @@ def test_clear_unconsumed_tail(self):
498490 ddata += dco .decompress (dco .unconsumed_tail )
499491 self .assertEqual (dco .unconsumed_tail , b"" )
500492
501- # TODO: RUSTPYTHON
493+ # TODO: RUSTPYTHON: Z_BLOCK support in flate2
502494 @unittest .expectedFailure
503495 def test_flushes (self ):
504496 # Test flush() with the various options, using all the
@@ -560,8 +552,6 @@ def test_empty_flush(self):
560552 dco = zlib .decompressobj ()
561553 self .assertEqual (dco .flush (), b"" ) # Returns nothing
562554
563- # TODO: RUSTPYTHON
564- @unittest .expectedFailure
565555 def test_dictionary (self ):
566556 h = HAMLET_SCENE
567557 # Build a simulated dictionary out of the words in HAMLET.
@@ -578,8 +568,6 @@ def test_dictionary(self):
578568 dco = zlib .decompressobj ()
579569 self .assertRaises (zlib .error , dco .decompress , cd )
580570
581- # TODO: RUSTPYTHON
582- @unittest .expectedFailure
583571 def test_dictionary_streaming (self ):
584572 # This simulates the reuse of a compressor object for compressing
585573 # several separate data streams.
@@ -652,8 +640,6 @@ def test_decompress_unused_data(self):
652640 self .assertEqual (dco .unconsumed_tail , b'' )
653641 self .assertEqual (dco .unused_data , remainder )
654642
655- # TODO: RUSTPYTHON
656- @unittest .expectedFailure
657643 # issue27164
658644 def test_decompress_raw_with_dictionary (self ):
659645 zdict = b'abcdefghijklmnopqrstuvwxyz'
@@ -829,7 +815,7 @@ def test_large_unconsumed_tail(self, size):
829815 finally :
830816 comp = uncomp = data = None
831817
832- # TODO: RUSTPYTHON
818+ # TODO: RUSTPYTHON: wbits=0 support in flate2
833819 @unittest .expectedFailure
834820 def test_wbits (self ):
835821 # wbits=0 only supported since zlib v1.2.3.5
@@ -997,8 +983,6 @@ def testDecompressUnusedData(self):
997983 self .assertEqual (text , self .TEXT )
998984 self .assertEqual (zlibd .unused_data , unused_data )
999985
1000- # TODO: RUSTPYTHON
1001- @unittest .expectedFailure
1002986 def testEOFError (self ):
1003987 zlibd = zlib ._ZlibDecompressor ()
1004988 text = zlibd .decompress (self .DATA )
@@ -1029,8 +1013,6 @@ def testPickle(self):
10291013 with self .assertRaises (TypeError ):
10301014 pickle .dumps (zlib ._ZlibDecompressor (), proto )
10311015
1032- # TODO: RUSTPYTHON
1033- @unittest .expectedFailure
10341016 def testDecompressorChunksMaxsize (self ):
10351017 zlibd = zlib ._ZlibDecompressor ()
10361018 max_length = 100
@@ -1062,8 +1044,6 @@ def testDecompressorChunksMaxsize(self):
10621044 self .assertEqual (out , self .BIG_TEXT )
10631045 self .assertEqual (zlibd .unused_data , b"" )
10641046
1065- # TODO: RUSTPYTHON
1066- @unittest .expectedFailure
10671047 def test_decompressor_inputbuf_1 (self ):
10681048 # Test reusing input buffer after moving existing
10691049 # contents to beginning
@@ -1086,8 +1066,6 @@ def test_decompressor_inputbuf_1(self):
10861066 out .append (zlibd .decompress (self .DATA [105 :]))
10871067 self .assertEqual (b'' .join (out ), self .TEXT )
10881068
1089- # TODO: RUSTPYTHON
1090- @unittest .expectedFailure
10911069 def test_decompressor_inputbuf_2 (self ):
10921070 # Test reusing input buffer by appending data at the
10931071 # end right away
@@ -1109,8 +1087,6 @@ def test_decompressor_inputbuf_2(self):
11091087 out .append (zlibd .decompress (self .DATA [300 :]))
11101088 self .assertEqual (b'' .join (out ), self .TEXT )
11111089
1112- # TODO: RUSTPYTHON
1113- @unittest .expectedFailure
11141090 def test_decompressor_inputbuf_3 (self ):
11151091 # Test reusing input buffer after extending it
11161092
0 commit comments