# fixture 'db_session' 未找到
可用 fixtures: cache, capfd, ...

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

## 根因

Fixture 名称拼写错误，定义在测试目录范围之外的 conftest.py 中，或者因插件未安装而未导入。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Create `tests/conftest.py` with `@pytest.fixture
def db_session(): ...` and ensure tests are under `tests/`.
   ```
2. **** (90% 成功率)
   ```
   `pip install pytest-django` then in pytest.ini: `[pytest]
DJANGO_SETTINGS_MODULE = myproj.settings`
   ```

## 无效尝试

- **** — Duplicates fixture logic across many test files and defeats the purpose of shared fixtures. (40% 失败率)
- **** — Shadows a built-in pytest fixture and causes unexpected behavior in other tests. (90% 失败率)
