Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix a bunch of zlib tests
  • Loading branch information
coolreader18 committed Feb 26, 2025
commit 8c5602f2fb84aacad2495f6b296ef74ef9e164ac
52 changes: 14 additions & 38 deletions Lib/test/test_zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
'requires Decompress.copy()')


# def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
# # Register "1.2.3" as "1.2.3.0"
# # or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
# v = zlib_version.split('-', 1)[0].split('.')
# if len(v) < 4:
# v.append('0')
# elif not v[-1].isnumeric():
# v[-1] = '0'
# return tuple(map(int, v))
#
#
# ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
# Register "1.2.3" as "1.2.3.0"
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
v = zlib_version.split('-', 1)[0].split('.')
if len(v) < 4:
v.append('0')
elif not v[-1].isnumeric():
v[-1] = '0'
return tuple(map(int, v))


ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()


# bpo-46623: When a hardware accelerator is used (currently only on s390x),
Expand Down Expand Up @@ -66,8 +66,6 @@

class VersionTestCase(unittest.TestCase):

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_library_version(self):
# Test that the major version of the actual library in use matches the
# major version that we were compiled against. We can't guarantee that
Expand Down Expand Up @@ -282,8 +280,6 @@ def test_64bit_compress(self, size):


class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
# Test compression object
def test_pair(self):
# straightforward compress/decompress objects
Expand All @@ -307,8 +303,6 @@ def test_pair(self):
self.assertIsInstance(dco.unconsumed_tail, bytes)
self.assertIsInstance(dco.unused_data, bytes)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_keywords(self):
level = 2
method = zlib.DEFLATED
Expand Down Expand Up @@ -466,8 +460,6 @@ def test_decompressmaxlen(self, flush=False):
def test_decompressmaxlenflush(self):
self.test_decompressmaxlen(flush=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_maxlenmisc(self):
# Misc tests of max_length
dco = zlib.decompressobj()
Expand Down Expand Up @@ -498,7 +490,7 @@ def test_clear_unconsumed_tail(self):
ddata += dco.decompress(dco.unconsumed_tail)
self.assertEqual(dco.unconsumed_tail, b"")

# TODO: RUSTPYTHON
# TODO: RUSTPYTHON: Z_BLOCK support in flate2
@unittest.expectedFailure
def test_flushes(self):
# Test flush() with the various options, using all the
Expand Down Expand Up @@ -560,8 +552,6 @@ def test_empty_flush(self):
dco = zlib.decompressobj()
self.assertEqual(dco.flush(), b"") # Returns nothing

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_dictionary(self):
h = HAMLET_SCENE
# Build a simulated dictionary out of the words in HAMLET.
Expand All @@ -578,8 +568,6 @@ def test_dictionary(self):
dco = zlib.decompressobj()
self.assertRaises(zlib.error, dco.decompress, cd)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_dictionary_streaming(self):
# This simulates the reuse of a compressor object for compressing
# several separate data streams.
Expand Down Expand Up @@ -652,8 +640,6 @@ def test_decompress_unused_data(self):
self.assertEqual(dco.unconsumed_tail, b'')
self.assertEqual(dco.unused_data, remainder)

# TODO: RUSTPYTHON
@unittest.expectedFailure
# issue27164
def test_decompress_raw_with_dictionary(self):
zdict = b'abcdefghijklmnopqrstuvwxyz'
Expand Down Expand Up @@ -829,7 +815,7 @@ def test_large_unconsumed_tail(self, size):
finally:
comp = uncomp = data = None

# TODO: RUSTPYTHON
# TODO: RUSTPYTHON: wbits=0 support in flate2
@unittest.expectedFailure
def test_wbits(self):
# wbits=0 only supported since zlib v1.2.3.5
Expand Down Expand Up @@ -997,8 +983,6 @@ def testDecompressUnusedData(self):
self.assertEqual(text, self.TEXT)
self.assertEqual(zlibd.unused_data, unused_data)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def testEOFError(self):
zlibd = zlib._ZlibDecompressor()
text = zlibd.decompress(self.DATA)
Expand Down Expand Up @@ -1029,8 +1013,6 @@ def testPickle(self):
with self.assertRaises(TypeError):
pickle.dumps(zlib._ZlibDecompressor(), proto)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def testDecompressorChunksMaxsize(self):
zlibd = zlib._ZlibDecompressor()
max_length = 100
Expand Down Expand Up @@ -1062,8 +1044,6 @@ def testDecompressorChunksMaxsize(self):
self.assertEqual(out, self.BIG_TEXT)
self.assertEqual(zlibd.unused_data, b"")

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_decompressor_inputbuf_1(self):
# Test reusing input buffer after moving existing
# contents to beginning
Expand All @@ -1086,8 +1066,6 @@ def test_decompressor_inputbuf_1(self):
out.append(zlibd.decompress(self.DATA[105:]))
self.assertEqual(b''.join(out), self.TEXT)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_decompressor_inputbuf_2(self):
# Test reusing input buffer by appending data at the
# end right away
Expand All @@ -1109,8 +1087,6 @@ def test_decompressor_inputbuf_2(self):
out.append(zlibd.decompress(self.DATA[300:]))
self.assertEqual(b''.join(out), self.TEXT)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_decompressor_inputbuf_3(self):
# Test reusing input buffer after extending it

Expand Down
2 changes: 1 addition & 1 deletion derive-impl/src/pymodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl ModuleItem for AttributeItem {
(
quote_spanned! { ident.span() => {
#let_obj
for name in [(#(#names,)*)] {
for name in [#(#names),*] {
vm.__module_set_attr(module, vm.ctx.intern_str(name), obj.clone()).unwrap();
}
}},
Expand Down
Loading