`test_warnings` not restoring filters for free threading tests
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug description:
PYTHONWARNINGS=default ./python.exe -W default -m test test_warnings
Using random seed: 2934466897
0:00:00 load avg: 8.99 mem: 287.4 MiB Run 1 test sequentially in a single process
0:00:00 load avg: 8.99 mem: 287.4 MiB [1/1] test_warnings
Warning -- warnings.filters was modified by test_warnings
Warning -- Before: (12918522352, [('default', None, <class 'Warning'>, None, 0)], [('default', None, <class 'Warning'>, None, 0)])
Warning -- After: (12918522352, [('default', None, <class 'Warning'>, None, 0)], [])
0:00:20 load avg: 7.32 mem: 392.4 MiB [1/1/1] test_warnings failed (env changed)
This appears to race because the setUp is calling resetwarnings without getting it's own context.
This does not appear on the Cpython CI since --py-debug is used I believe which starts the warnings filter by default as an empty list so less likely to race, this occurred to me when running cpython tests against a release build and this test would not work.
The root cause I think is due to regr test asserting that the env hasn't been changed, however due to starting the test with warnings that are cleared this does not hold true
CPython versions tested on:
CPython main branch
Operating systems tested on:
Macos
Linked PRs
- gh-155609
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行 PYTHONWARNINGS=default ./python.exe -W default -m test test_warnings,并检查 resetwarnings 附近的 test_warnings 设置。查看回归测试如何比较前后的 warnings 环境;当测试恢复其过滤器且命令不再报告环境发生变化时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- testing-qa
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100