# assert 5 == 3 where 5 = func()

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

## 根因

pytest 的断言重写未能生成详细的内部信息，因为测试模块在插件注册前被导入，或者该模块是未被 pytest 收集的插件/入口点。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Rename `checks.py` to `test_checks.py` and run `pytest test_checks.py -v`. Ensure no `conftest.py` imports the module early.
   ```
2. **** (85% 成功率)
   ```
   In `conftest.py`: `import pytest; pytest.register_assert_rewrite('myapp.tests.helpers')` then import helpers.
   ```

## 无效尝试

- **** — Manual messages still hide the intermediate values of subexpressions, defeating the purpose of assertion rewriting. (60% 失败率)
- **** — Disabling plugins also disables assertion rewriting from the built-in plugin, making output worse. (80% 失败率)
