Missing unsafe keyword on unittest.mock.patch, unittest.mock.patch.object, and create_autospec
未關閉
還沒有人認領這個 Issue。
docs
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Documentation
Unsafe keyword missing for both unittest.mock.patch and unittest.mock.patch.object
Current docs:
.. function:: patch(target, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
.. function:: patch.object(target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
Implementation
def patch(
target, new=DEFAULT, spec=None, create=False,
spec_set=None, autospec=None, new_callable=None, *, unsafe=False, **kwargs
):
def _patch_object(
target, attribute, new=DEFAULT, spec=None,
create=False, spec_set=None, autospec=None,
new_callable=None, *, unsafe=False, **kwargs
):
In fact, it's already there in patch docstring, just not in the docs for some reason:
Patch will raise a `RuntimeError` if passed some common misspellings of
the arguments autospec and spec_set. Pass the argument `unsafe` with the
value True to disable that check.
Linked PRs
- gh-136208
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 unittest.mock 中 patch 和 patch.object 的文件條目開始,將其中顯示的簽章與 issue 中展示的實作簽章進行比較。更新文件,以公開 patch、patch.object 和 create_autospec 的 unsafe 關鍵字,然後驗證轉譯後的簽章及其周圍的說明與現有 docstring 一致。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100