# AssertionError: assert False
 +  where False = <function is_valid at 0x...>(123)

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

## 根因

断言重写被禁用（通过 --assert=plain、PYTHONDONTWRITEBYTECODE 或插件冲突），pytest 无法内省产生 False 的子表达式，只打印原始 assert。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   # pytest.ini
[pytest]
addopts = --assert=rewrite
# ensure no PYTHONDONTWRITEBYTECODE=1 in env
   ```
2. **** (85% 成功率)
   ```
   # conftest.py
import pytest
pytest.register_assert_rewrite('tests.test_api')
   ```

## 无效尝试

- **** — -s disables output capture, not assertion rewriting; the introspection message remains absent. (80% 失败率)
- **** — This defeats the purpose of pytest's introspection and pollutes test output with manual prints. (60% 失败率)
