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 摘要。