# 失败: DOCTEST ... 预期:
    4
实际:
    5

- **ID:** `python/pytest-doctest-failure`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

文档字符串中的 doctest 示例产生的输出与预期不同。这可能是由于函数更改或环境相关的输出。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   If the change is intentional, update the docstring to match the new output.
   ```
2. **** (90% 成功率)
   ```
   >>> print(some_func())  # doctest: +ELLIPSIS
Hello ...
This allows parts of the output to vary.
   ```

## 无效尝试

- **** — This loses the documentation and test coverage. (80% 失败率)
- **** — This skips the test but doesn't fix the discrepancy. (70% 失败率)
