python config_error ai_generated true

PluginValidationError: unknown hook 'pytest_collection_modifyitems' in plugin <module 'conftest' from '/path/to/conftest.py'>

ID: python/pytest-missing-plugin-error

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.4.0 active

Root Cause

conftest.py 中定义了 pytest 不认识的函数名,拼写错误或版本不兼容

generic

中文

conftest.py 中定义了 pytest 不认识的函数名,拼写错误或版本不兼容

Workarounds

  1. 90% success
    确保函数名正确,如 pytest_collection_modifyitems 应为 pytest_collection_modifyitems
  2. 60% success
    pip install --upgrade pytest

Dead Ends

Common approaches that don't work:

  1. 70% fail

    会丢失所有自定义配置和 fixture

  2. 40% fail

    如果函数名本身就是自定义的,需要检查是否应该用其他钩子