# 失败示例:
    print({'a': 1, 'b': 2})
期望:
    {'a': 1, 'b': 2}
实际:
    {'a': 1, 'b': 2}

1 项存在失败

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

## 根因

字典顺序在不同 Python 版本间不同，或输出存在尾随空白/顺序差异。未启用 NORMALIZE_WHITESPACE 或 ELLIPSIS 时，doctest 要求输出逐字节一致。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Enable normalization in pytest.ini:
  [tool.pytest.ini_options]
  doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
Or in docstring:
  >>> print(d)  # doctest: +NORMALIZE_WHITESPACE
   ```
2. **** (92% 成功率)
   ```
   Sort dict output explicitly in the docstring example:
  >>> sorted(d.items())
  [('a', 1), ('b', 2)]
   ```

## 无效尝试

- **** — Breaks on other Python versions where dict ordering or repr differ. (75% 失败率)
- **** — Loses documentation test coverage; hides real regressions. (50% 失败率)
