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

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

## 根因

Doctest 比较精确的字符串输出。Python 3.7+ 中字典按插入顺序排列，因此期望输出必须与实际插入顺序一致，或使用排序输出。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   >>> print(dict(sorted({'b': 2, 'a': 1}.items())))
{'a': 1, 'b': 2}
   ```
2. **** (80% 成功率)
   ```
   >>> print({'a': 1, 'b': 2})  # doctest: +ELLIPSIS
{...}
   ```

## 无效尝试

- **** — Skips the test entirely, losing coverage for the function's behavior. (85% 失败率)
- **** — Hash seed affects set ordering, not dict insertion order in modern Python; dicts preserve insertion order regardless. (90% 失败率)
