python / python/cpython

Augment functools.cached_property tests for set/delete

未关闭
#142,252 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

cached_property supports set and delete but this is not currently tested.

Minimal test extending TestCachedProperty.test_cached:

class TestCachedProperty(unittest.TestCase):
    def test_cached(self):
        item = CachedCostItem()
        self.assertEqual(item.cost, 2)
        self.assertEqual(item.cost, 2) # not 3

        item.cost = 42
        self.assertEqual(item.cost, 42)

        del item.cost
        self.assertEqual(item.cost, 3)
        self.assertEqual(item.cost, 3) # not 4
Linked PRs
  • gh-142645
  • gh-143393

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 issue 中指定的位置 Lib/test/test_functools.py 中的 TestCachedProperty.test_cached 开始。先运行针对性的 functools 测试,然后按所示扩展此测试,以覆盖设置和删除 cached property 的情况。新的 assertions 通过且现有的 cached property 行为仍得到覆盖,即表示完成。

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

评估

技术栈
python
领域
testing-qa
Issue 类型
功能
难度
1/5
预计耗时
1 小时以内
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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