Pytest 在升级到 pytest 7 后不起作用。

huangapple go评论57阅读模式
英文:

Pytest isn't working after update to pytest 7

问题

我安装了Python 3.11,并使用pip uninstall pytestpip install pytest更新了pytest包。

我编写了一个小脚本来测试它

但是没有任何运行,并且我得到了这个输出

可能的问题是什么?

英文:

I installed python 3.11 and updated the pytest package with pip uninstall pytest and pip install pytest

I wrote a small script to test it

def test_pytest_0():
 RESULT_SOLL=True
 RESULT_EXTERNAL=True
 Test_STEP_INFO='MessageBox Yes NO Run / schritt nummer 2'

 print(' Test_STEP_COMMENT=MessageBox Fragt nach : ok die Antwort war : yes') 

 assert  RESULT_SOLL==RESULT_EXTERNAL 
 print(RESULT_SOLL,RESULT_EXTERNAL,Test_STEP_INFO)
def test_pytest_1():
 RESULT_SOLL=True
 RESULT_EXTERNAL=True
 Test_STEP_INFO='MessageBox Yes NO Run / schritt nummer 3'

 print(' Test_STEP_COMMENT=MessageBox Fragt nach : was ok die Antwort war : yes') 

 assert  RESULT_SOLL==RESULT_EXTERNAL 
 print(RESULT_SOLL,RESULT_EXTERNAL,Test_STEP_INFO)

But nothing ran and I got this output

PS C:\Users\hasan.edrees\Desktop\Test_Platform_Gui\Arduino_with_GUI\python> pytest test_pytest_.py
================================================= test session starts =================================================
platform win32 -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: C:\Users\hasan.edrees\Desktop\Test_Platform_Gui\Arduino_with_GUI\python
collected 2 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 269, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 322, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 333, in pytest_collection
INTERNALERROR>     session.perform_collect()
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 667, in perform_collect
INTERNALERROR>     self.config.pluginmanager.check_pending()
INTERNALERROR>   File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_manager.py", line 262, in check_pending
INTERNALERROR>     raise PluginValidationError(
INTERNALERROR> pluggy._manager.PluginValidationError: unknown hook 'pytest_html_report_title' in plugin <module 'python.conftest' from 'C:\\Users\\hasan.edrees\\Desktop\\Test_Platform_Gui\\Arduino_with_GUI\\python\\conftest.py'>

================================================ no tests ran in 0.01s ================================================
PS C:\Users\hasan.edrees\Desktop\Test_Platform_Gui\Arduino_with_GUI\python>

What could be the problem?

答案1

得分: 0

错误PluginValidationError: unknown hook 'pytest_html_report_title'意味着conftest.py中的钩子pytest_html_report_title未被pytest识别。

由于您已更新Python版本,您还需要在新解释器中重新安装pytest-html插件

pip install pytest-html
英文:

The error PluginValidationError: unknown hook 'pytest_html_report_title' means the hook pytest_html_report_title in conftest.py is not recognized by pytest.

Since you updated your Python version you also need to reinstall the pytest-html plugin in the new interpreter

pip install pytest-html

huangapple
  • 本文由 发表于 2023年6月1日 16:09:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76379882.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定