python
config_error
ai_generated
true
未找到 fixture 'test_data'
fixture 'test_data' not found
ID: python/pytest-fixture-not-found
80%修复率
88%置信度
0证据数
2024-06-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
fixture 定义在 conftest.py 中,但该文件不在测试文件所在目录或其父目录中,或者 fixture 名称拼写错误。
English
The fixture is defined in a conftest.py file that is not in the same directory or a parent directory of the test file, or the fixture name is misspelled.
解决方案
-
98% 成功率
Create conftest.py in the test directory and define the fixture there.
-
90% 成功率
Verify the fixture name and that it's defined at module level.
无效尝试
常见但无效的做法:
-
50% 失败
If the fixture is needed by multiple tests in different files, it won't be available.
-
80% 失败
Fixture names are case-sensitive and must match exactly.