python config_error ai_generated true

插件验证错误:conftest.py 中的插件包含未知钩子 'pytest_collection_modifyitems'

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

ID: python/pytest-missing-plugin-error

其他格式: JSON · Markdown 中文 · English
80%修复率
83%置信度
0证据数
2024-04-18首次发现

版本兼容性

版本状态引入弃用备注
7.4.0 active

根因分析

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

English

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

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. 70% 失败

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

  2. 40% 失败

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