# 未找到夹具 'my_fixture'

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

## 根因

pytest 未加载包含夹具的 conftest.py 文件。这发生在 conftest.py 位于错误目录、不在测试路径中，或 rootdir 配置错误时。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   # Place conftest.py in the tests/ directory or project root
# pytest automatically loads conftest.py from rootdir and test directories
   ```
2. **** (85% 成功率)
   ```
   pytest --confcutdir=tests/
   ```

## 无效尝试

- **** — This duplicates the fixture across multiple test files and defeats the purpose of conftest.py for sharing fixtures. (75% 失败率)
- **** — pytest does not load fixtures from __init__.py. Only conftest.py files are automatically loaded. (90% 失败率)
