python
runtime_error
ai_generated
true
失败: DOCTEST ... 预期: 4 实际: 5
Failed: DOCTEST ... Expected: 4 Got: 5
ID: python/pytest-doctest-failure
80%修复率
85%置信度
0证据数
2024-02-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
文档字符串中的 doctest 示例产生的输出与预期不同。这可能是由于函数更改或环境相关的输出。
English
A doctest example in a docstring produced a different output than expected. This can be due to changes in the function or environment-dependent output.
解决方案
-
95% 成功率
If the change is intentional, update the docstring to match the new output.
-
90% 成功率
>>> print(some_func()) # doctest: +ELLIPSIS Hello ... This allows parts of the output to vary.
无效尝试
常见但无效的做法:
-
80% 失败
This loses the documentation and test coverage.
-
70% 失败
This skips the test but doesn't fix the discrepancy.