# PytestReturnNotNoneWarning: 期望返回 None，但 tests/test_x.py::test_foo 返回了 1，这将在未来版本的 pytest 中成为错误

- **ID:** `python/pytest-return-not-none`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试函数返回值而非使用 assert。常见于移植 unittest 风格测试，或辅助函数返回了本意作为断言的真值。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   # before
def test_foo():
    return compute() == 1

# after
def test_foo():
    assert compute() == 1
   ```
2. **** (90% 成功率)
   ```
   [tool.pytest.ini_options]
filterwarnings = ["error::pytest.PytestReturnNotNoneWarning"]
   ```

## 无效尝试

- **** — Silences the warning but the test may pass even when the intended condition is false, because no assertion occurs. (70% 失败率)
- **** — Hides a real bug: the test is not actually asserting anything. (85% 失败率)
