pluggy._manager.PluginValidationError:插件中未知的挂钩“pytest_html_results_table_header”<module 'conftest'

问题描述 投票:0回答:1

我尝试在 Windows 10 计算机上运行 Pytest,但出现以下错误:

Collecting ... collected 1 item
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\_pytest\main.py", line 270, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\_pytest\main.py", line 323, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\pluggy\_hooks.py", line 493, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\pluggy\_manager.py", line 115, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\pluggy\_callers.py", line 152, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\pluggy\_result.py", line 114, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\pluggy\_callers.py", line 77, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\_pytest\main.py", line 334, in pytest_collection
INTERNALERROR>     session.perform_collect()
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\_pytest\main.py", line 666, in perform_collect
INTERNALERROR>     self.config.pluginmanager.check_pending()
INTERNALERROR>   File "E:\voicegain\venv\Lib\site-packages\pluggy\_manager.py", line 370, in check_pending
INTERNALERROR>     raise PluginValidationError(
INTERNALERROR> pluggy._manager.PluginValidationError: unknown hook 'pytest_html_results_table_header' in plugin <module 'conftest' from 'E:\\conftest.py'>

我正在使用以下库:

selenium==4.12.0
pytest==7.2.2
chromedriver-py==116.0.5845.96
pytest-html-reporter==0.2.9
logging==0.4.9.6
postpy2==0.0.8

根据线程由于 pytest-json-report 插件导致的 Pytestpluggy._manager.PluginValidationError 我添加了下面的代码,但仍然没有成功。

@pytest.hookimpl(optionalhook=True)
def  pytest_json_runtest_metadata(item, call):
python pytest
1个回答
0
投票

如此处所述,更新到 pytest 7 后,Pytest 无法工作尝试

pip install pytest-html
© www.soinside.com 2019 - 2024. All rights reserved.