Add reproducibility test for `gzip.compress()`
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
The issue https://github.com/python/cpython/issues/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 https://github.com/python/cpython/issues/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
Linked PRs
- gh-151214
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
开始之前,检查链接的 PR gh-151214,并找到现有的 gzip 模块测试。添加 issue 中所示的 gzip.compress() 可复现性检查,然后确认预期输出仍然稳定,并说明 What's New 中任何有意的更改。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- testing-qa
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100