python / python/cpython

Make Memory-Related Tests Less Fragile

未关闭
#121,978 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

tests type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Feature or enhancement

Proposal:

There are a number of tests that check various aspects of memory management, typically related to some specific module or feature. Nearly every one of these tests is fairly tightly coupled to the fine details of our memory management implementation, usually tied to specific numbers.

This makes the tests fragile, often breaking with even slight changes to some aspect of memory management. [^1]

[^1]: To be fair, we don't make changes to memory management very often; clearly these tests aren't breaking all the time.

For example, in https://github.com/python/cpython/pull/121134#issuecomment-2233412265, @Fidget-Spinner says:

It fails

    test.test_gdb.test_pretty_print test_capi test_exceptions
    test_regrtest test_repl test_sys test_tracemalloc

mainly because they count allocations/test out of memory situations, and the hashtable adds random allocations which breaks their careful calculations.

[^2]

[^2]: Note that those aren't necessarily the only tests that need attention here.

Ideally, we would find a way to make such tests less coupled to specific numbers, without sacrificing the accuracy of the behavior checks they are making.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 issue 中提到的内存敏感测试:test_gdb.test_pretty_print、test_capi、test_exceptions、test_regrtest、test_repl、test_sys 和 test_tracemalloc。确定哪些分配或内存不足断言依赖固定计数,然后确定在不使用这些精确数字的情况下,如何仍能准确地检查其行为。完成的标准是,受影响的测试能够容忍相关的内存管理变更,同时仍能检测出回归。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
testing-qa
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。