# snapshot_assertion_failed: 快照 'test_render' 不匹配。
接收值与存储的快照不匹配。
使用 --snapshot-update 重新生成。

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

## 根因

快照测试（pytest-snapshot、syrupy、snapshottest）将输出与存储文件比较；输出任何变化（有意或无意）都会导致不匹配。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   pytest tests/test_render.py -k test_render --snapshot-details
# review the diff, then
pytest --snapshot-update tests/test_render.py
   ```
2. **** (90% 成功率)
   ```
   def sanitize(output):
    output.pop('timestamp', None)
    output['id'] = '<id>'
    return output

def test_render(snapshot):
    snapshot.assert_match(sanitize(render()), 'render.json')
   ```

## 无效尝试

- **** — Accepts whatever the code currently produces, including regressions; snapshots become rubber stamps. (90% 失败率)
- **** — Next run recreates it from current (possibly buggy) output, losing the historical baseline. (85% 失败率)
- **** — Hides the diff and prevents catching real regressions; xfail state tends to linger. (80% 失败率)
