51Testing软件测试论坛

标题: 求助,pytest 执行 pytest.main问题! [打印本页]

作者: 测试积点老人    时间: 2021-9-2 13:30
标题: 求助,pytest 执行 pytest.main问题!
pytest 执行 pytest.main(['-s', '-q', '--alluredir', 'report/result', 'test.py']) 时报错 AttributeError: module 'allure' has no attribute 'severity_level',网上说卸载后安装新版本即可,但是试过还是有这个问题测试代码:
  1. import pytest
  2. import os

  3. class TestPytest(object):

  4. def test_one(self):
  5. print("test_one 方法执行")
  6. assert 1 == 1

  7. def test_two(self):
  8. print("test_two 方法执行")
  9. assert "s" in "love"

  10. def test_three(self):
  11. print("test_three 方法执行")
  12. assert 3 - 2 == 1

  13. if name == "main":
  14. pytest.main(['-s', '-q', '--alluredir', 'report/result', 'test.py'])
  15. 完整报错:
  16. Traceback (most recent call last):
  17. File "F:\pycharm\PyCharm Community Edition 2021.1.1\plugins\python-ce\helpers\pycharm_jb_pytest_runner.py", line 46, in
  18. sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
  19. File "F:\python\lib\site-packages_pytest\config_init.py", line 143, in main
  20. config = _prepareconfig(args, plugins)
  21. File "F:\python\lib\site-packages_pytest\config__init.py", line 319, in _prepareconfig
  22. pluginmanager=pluginmanager, args=args
  23. File "F:\python\lib\site-packages\pluggy\hooks.py", line 286, in __call_
  24. return self.hookexec(self, self.get_hookimpls(), kwargs)
  25. File "F:\python\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
  26. return self._inner_hookexec(hook, methods, kwargs)
  27. File "F:\python\lib\site-packages\pluggy\manager.py", line 87, in
  28. firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  29. File "F:\python\lib\site-packages\pluggy\callers.py", line 203, in _multicall
  30. gen.send(outcome)
  31. File "F:\python\lib\site-packages_pytest\helpconfig.py", line 100, in pytest_cmdline_parse
  32. config: Config = outcome.get_result()
  33. File "F:\python\lib\site-packages\pluggy\callers.py", line 80, in get_result
  34. raise ex[1].with_traceback(ex[2])
  35. File "F:\python\lib\site-packages\pluggy\callers.py", line 187, in _multicall
  36. res = hook_impl.function(*args)
  37. File "F:\python\lib\site-packages_pytest\config__init.py", line 1003, in pytest_cmdline_parse
  38. self.parse(args)
  39. File "F:\python\lib\site-packages_pytest\config__init.py", line 1283, in parse
  40. self._preparse(args, addopts=addopts)
  41. File "F:\python\lib\site-packages_pytest\config__init.py", line 1172, in _preparse
  42. self.pluginmanager.load_setuptools_entrypoints("pytest11")
  43. File "F:\python\lib\site-packages\pluggy\manager.py", line 300, in load_setuptools_entrypoints
  44. self.register(plugin, name=ep.name)
  45. File "F:\python\lib\site-packages_pytest\config__init_.py", line 436, in register
  46. ret: Optional[str] = super().register(plugin, name)
  47. File "F:\python\lib\site-packages\pluggy\manager.py", line 127, in register
  48. hook._maybe_apply_history(hookimpl)
  49. File "F:\python\lib\site-packages\pluggy\hooks.py", line 333, in _maybe_apply_history
  50. res = self._hookexec(self, [method], kwargs)
  51. File "F:\python\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
  52. return self._inner_hookexec(hook, methods, kwargs)
  53. File "F:\python\lib\site-packages\pluggy\manager.py", line 87, in
  54. firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  55. File "F:\python\lib\site-packages\pluggy\callers.py", line 208, in _multicall
  56. return outcome.get_result()
  57. File "F:\python\lib\site-packages\pluggy\callers.py", line 80, in get_result
  58. raise ex[1].with_traceback(ex[2])
  59. File "F:\python\lib\site-packages\pluggy\callers.py", line 187, in _multicall
  60. res = hook_impl.function(*args)
  61. File "F:\python\lib\site-packages\allure_pytest\plugin.py", line 48, in pytest_addoption
  62. severities = [x.value for x in list(allure.severity_level)]
  63. AttributeError: module 'allure' has no attribute 'severity_level'
复制代码




作者: 海海豚    时间: 2021-9-3 09:20
重新下载下库试试
作者: qqq911    时间: 2021-9-3 11:12
卸载是不是没卸载干净
作者: jingzizx    时间: 2021-9-3 15:32
要不就是安装的有问题,有不就是环境缺少内容




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2