Skip to content

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

Merged
rhpvorderman merged 2 commits into
pycompression:developfrom
ptweezy:test-igzipfile-isal-output
Nov 2, 2026
Merged

rhpvorderman merged 2 commits 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 replaces isal_zlib.compressobj() with a wrapper that records its arguments. It checks that opening an IGzipFile for writing calls it once with the given level and raw deflate settings, and that f.compress is an isal_zlib.Compress.

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.

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.

@rhpvorderman rhpvorderman left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not assert isinstance(f.compress, type(isal_zlib.decompressobj()) ?

EDIT: Oh I see, this also tests whether the correct level is passed.

Rather than byte for byte testing I prefer to have something that tests the actual parameters rather than the result.

The review asked for a test of the parameters instead of a byte-for-byte
comparison of the deflate data. The test now records the calls to
isal_zlib.compressobj and checks that f.compress is an isal_zlib.Compress.
@ptweezy

ptweezy commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Changed the test to check the parameters. It now replaces isal_zlib.compressobj with a wrapper that records its arguments. It checks that IGzipFile calls it once with the given level and raw deflate settings, and that f.compress is an isal_zlib.Compress.

@ptweezy
ptweezy requested a review from rhpvorderman November 2, 2026 11:14
@rhpvorderman

Copy link
Copy Markdown
Collaborator

LGTM!

@rhpvorderman
rhpvorderman merged commit aca52b4 into pycompression:develop Nov 2, 2026
22 checks passed
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.

2 participants