8000 Add reproducibility test for `gzip.compress()` · Issue #131697 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Add reproducibility test for gzip.compress() #131697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
za3k opened this issue Mar 24, 2025 · 0 comments
Open

Add reproducibility test for gzip.compress() #131697

za3k opened this issue Mar 24, 2025 · 0 comments
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@za3k
Copy link
za3k commented Mar 24, 2025

The issue #112346 was reported, which was a failure to keep reproducibility in gzip module output from Python 3.10 to 3.11.

There was a fix discussed and rejected in #112346

I think it makes sense not to actually change things back, but failing to merge the PR means we also failed to add unit tests.

Can we please add a general-purpose, fragile reproducibility test for the gzip module, so that this problem does not recur?

Ex. test that the output of gzip.compress("Hello world") remains stable

def test_gzip_reproducibility():
    """If this test fails, gzip.compress does not give reproducible output. Either fix that, or document the change in What's New and change the constant 'expected' below."""
    expected = b'\x1f\x8b\x08\x00\xa2\xd2\xe1g\x02\xff\xf3H\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00R\x9e\xd6\x8b\x0b\x00\x00\x00'
    assert gzip.compress(b"Hello world") == expected

    expected = 
b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xf3H\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00R\x9e\xd6\x8b\x0b\x00\x00\x00'
    assert gzip.compress(b"Hello world", mtime=0) == expected    
@za3k za3k added the type-bug An unexpected behavior, bug, or error label Mar 24, 2025
@picnixz picnixz changed the title Request for unit test Add reproducibility test for gzip.compress() Mar 24, 2025
@picnixz picnixz added type-feature A feature request or enhancement tests Tests in the Lib/test dir and removed type-bug An unexpected behavior, bug, or error labels Mar 24, 2025
Sign up for free to join this conversation on GitHub 51A6 . Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

2 participants
0