【Python】AttributeError: 'PytestPluginManager' object has no attribute 'addhooks' / pytest-html

一、报错

 

 

PS E:\WebUIAutomatedTest> pytest --html=report.html                                                                 
Traceback (most recent call last):
  File "D:\Python3.9.12\AZ\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Python3.9.12\AZ\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Python3.9.12\AZ\Scripts\pytest.exe\__main__.py", line 7, in <module>
  File "D:\Python3.9.12\AZ\lib\site-packages\_pytest\config\__init__.py", line 187, in console_main
    code = main()
  File "D:\Python3.9.12\AZ\lib\site-packages\_pytest\config\__init__.py", line 145, in main
    config = _prepareconfig(args, plugins)
  File "D:\Python3.9.12\AZ\lib\site-packages\_pytest\config\__init__.py", line 324, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "D:\Python3.9.12\AZ\lib\site-packages\_pytest\helpconfig.py", line 102, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
    return self._inner_hookexec(hook, methods, kwargs)
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "D:\Python3.9.12\AZ\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "D:\Python3.9.12\AZ\lib\site-packages\pytest_html\plugin.py", line 31, in pytest_addhooks
    pluginmanager.addhooks(newhooks)
AttributeError: 'PytestPluginManager' object has no attribute 'addhooks'
PS E:\WebUIAutomatedTest>

 

二、解决

重装一下pytest-html包 换个最新版本就行了(原:pytest-html==1.3,现:pytest-html==3.1.1)

pip uninstall pytest-html

pip install pytest-html

 

 

posted @ 2022-07-22 14:14  淡怀  阅读(220)  评论(0编辑  收藏  举报