circuitpython/tests/extmod/uzlib_decompio.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
761 B
Python
Raw Normal View History

try:
2023-08-22 11:15:46 -04:00
import zlib
import io
2017-02-15 01:56:22 +03:00
except ImportError:
print("SKIP")
raise SystemExit
2023-08-22 11:15:46 -04:00
try:
zlib.decompIO
except AttributeError:
print("SKIP")
raise SystemExit
# Raw DEFLATE bitstream
2021-03-15 19:27:36 +05:30
buf = io.BytesIO(b"\xcbH\xcd\xc9\xc9\x07\x00")
inp = zlib.DecompIO(buf, -8)
print(buf.seek(0, 1))
print(inp.read(1))
print(buf.seek(0, 1))
print(inp.read(2))
print(inp.read())
print(buf.seek(0, 1))
print(inp.read(1))
print(inp.read())
print(buf.seek(0, 1))
# zlib bitstream
2021-03-15 19:27:36 +05:30
inp = zlib.DecompIO(io.BytesIO(b"x\x9c30\xa0=\x00\x00\xb3q\x12\xc1"))
print(inp.read(10))
print(inp.read())
# zlib bitstream, wrong checksum
2021-03-15 19:27:36 +05:30
inp = zlib.DecompIO(io.BytesIO(b"x\x9c30\xa0=\x00\x00\xb3q\x12\xc0"))
try:
print(inp.read())
except OSError as e:
print(repr(e))