python config_error ai_generated true

fixture 'test_data' not found

ID: python/pytest-fixture-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-06-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

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.

generic

中文

fixture 定义在 conftest.py 中,但该文件不在测试文件所在目录或其父目录中,或者 fixture 名称拼写错误。

Workarounds

  1. 98% success
    Create conftest.py in the test directory and define the fixture there.
  2. 90% success
    Verify the fixture name and that it's defined at module level.

Dead Ends

Common approaches that don't work:

  1. 50% fail

    If the fixture is needed by multiple tests in different files, it won't be available.

  2. 80% fail

    Fixture names are case-sensitive and must match exactly.