python
config_error
ai_generated
true
夹具查找错误:在可用夹具中找不到 'db',可用夹具包括 tmpdir、capsys
FixtureLookupError: fixture 'db' not found in available fixtures: ['tmpdir', 'capsys']
ID: python/pytest-fixure-order-error
80%修复率
89%置信度
0证据数
2024-10-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.4.0 | active | — | — | — |
根因分析
测试函数引用了未定义的 fixture 名称
English
测试函数引用了未定义的 fixture 名称
解决方案
-
95% 成功率
@pytest.fixture def db(): ...
-
85% 成功率
确保 fixture 名称一致
无效尝试
常见但无效的做法:
-
40% 失败
可能与其他 fixture 冲突
-
90% 失败
pytest 不支持该参数