python / python/cpython

doctest: Allow checking for Traceback context errors

未關閉
#122,916 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:

If the error thrown in a doctest command is a ValueError, and that error object has a __context__ of RuntimeError, it would be nice to be able to do this:

>>> function_that_raises()
Traceback (most recent call last):
  ...
RuntimeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...
ValueError

And a similar thing for __cause__ but with the different line of text in the middle.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

I did make a discourse post, but it only got a like and no comments :)

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 doctest 的 traceback 檢查實作及其現有測試開始;該 issue 未提供檔案路徑。重現所示的 context 情況,並將其與提議的 cause 變體進行比較,然後為所要求的中間 traceback 文字新增覆蓋測試,並驗證 doctest 輸出。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
testing-qa
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。