python config_error ai_generated true

FixtureLookupError: fixture 'db' not found in available fixtures: ['tmpdir', 'capsys']

ID: python/pytest-fixure-order-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-10-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.4.0 active

Root Cause

测试函数引用了未定义的 fixture 名称

generic

中文

测试函数引用了未定义的 fixture 名称

Workarounds

  1. 95% success
    @pytest.fixture
    def db(): ...
  2. 85% success
    确保 fixture 名称一致

Dead Ends

Common approaches that don't work:

  1. 40% fail

    可能与其他 fixture 冲突

  2. 90% fail

    pytest 不支持该参数