Skip to content

Test that IGzipFile compresses with isal_zlib at the given level - #308

Open
ptweezy wants to merge 1 commit into
pycompression:developfrom
ptweezy:test-igzipfile-isal-output
Open

ptweezy wants to merge 1 commit into
pycompression:developfrom
ptweezy:test-igzipfile-isal-output

Conversation

@ptweezy

@ptweezy ptweezy commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

When IGzipFile.__init__() doesn't set self.compress, GzipFile compresses with zlib instead, and no test checked for that. The new test compares the deflate data that IGzipFile writes at each level with the output of isal_zlib.compressobj(), byte for byte.

To test it, I removed that line, and in another copy, always passed level 2 to compressobj(). The old tests in tests/test_igzip.py and the gzip compliance tests pass in both cases. The new test fails at all four levels with the first change, and at levels 0, 1, and 3 with the second.

The test writes 30,000 bytes. They fit in the write buffer that GzipFile has on Python 3.12 and later, so IGzipFile compresses them with one compress() call, like the compressobj() call it is compared with.

This PR changes only tests, so it has no CHANGELOG entry.

Checklist

  • Pull request details were added to CHANGELOG.rst
  • Documentation was updated (if needed)

When IGzipFile.__init__ does not set self.compress, GzipFile compresses with zlib instead, and the igzip tests still passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant