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

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

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

  1. def test_pytest_0():
  2. RESULT_SOLL=True
  3. RESULT_EXTERNAL=True
  4. Test_STEP_INFO='MessageBox Yes NO Run / schritt nummer 2'
  5. print(' Test_STEP_COMMENT=MessageBox Fragt nach : ok die Antwort war : yes')
  6. assert RESULT_SOLL==RESULT_EXTERNAL
  7. print(RESULT_SOLL,RESULT_EXTERNAL,Test_STEP_INFO)
  8. def test_pytest_1():
  9. RESULT_SOLL=True
  10. RESULT_EXTERNAL=True
  11. Test_STEP_INFO='MessageBox Yes NO Run / schritt nummer 3'
  12. print(' Test_STEP_COMMENT=MessageBox Fragt nach : was ok die Antwort war : yes')
  13. assert RESULT_SOLL==RESULT_EXTERNAL
  14. print(RESULT_SOLL,RESULT_EXTERNAL,Test_STEP_INFO)

But nothing ran and I got this output

  1. PS C:\Users\hasan.edrees\Desktop\Test_Platform_Gui\Arduino_with_GUI\python> pytest test_pytest_.py
  2. ================================================= test session starts =================================================
  3. platform win32 -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
  4. rootdir: C:\Users\hasan.edrees\Desktop\Test_Platform_Gui\Arduino_with_GUI\python
  5. collected 2 items
  6. INTERNALERROR> Traceback (most recent call last):
  7. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 269, in wrap_session
  8. INTERNALERROR> session.exitstatus = doit(config, session) or 0
  9. INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^
  10. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 322, in _main
  11. INTERNALERROR> config.hook.pytest_collection(session=session)
  12. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_hooks.py", line 265, in __call__
  13. INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  14. INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  15. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
  16. INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  17. INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  18. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_callers.py", line 60, in _multicall
  19. INTERNALERROR> return outcome.get_result()
  20. INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^
  21. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_result.py", line 60, in get_result
  22. INTERNALERROR> raise ex[1].with_traceback(ex[2])
  23. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_callers.py", line 39, in _multicall
  24. INTERNALERROR> res = hook_impl.function(*args)
  25. INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
  26. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 333, in pytest_collection
  27. INTERNALERROR> session.perform_collect()
  28. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\_pytest\main.py", line 667, in perform_collect
  29. INTERNALERROR> self.config.pluginmanager.check_pending()
  30. INTERNALERROR> File "C:\Users\hasan.edrees\AppData\Local\Programs\Python\Python311\Lib\site-packages\pluggy\_manager.py", line 262, in check_pending
  31. INTERNALERROR> raise PluginValidationError(
  32. 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'>
  33. ================================================ no tests ran in 0.01s ================================================
  34. 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插件

  1. 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

  1. 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:

确定