51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3887|回复: 3
打印 上一主题 下一主题

求助,pytest 执行 pytest.main问题!

[复制链接]
  • TA的每日心情
    无聊
    昨天 09:47
  • 签到天数: 528 天

    连续签到: 1 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2021-9-2 13:30:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1测试积点
    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'
    复制代码



    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    8 小时前
  • 签到天数: 1803 天

    连续签到: 2 天

    [LV.Master]测试大本营

    2#
    发表于 2021-9-3 09:20:05 | 只看该作者
    重新下载下库试试
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    7 小时前
  • 签到天数: 1518 天

    连续签到: 2 天

    [LV.Master]测试大本营

    3#
    发表于 2021-9-3 11:12:15 | 只看该作者
    卸载是不是没卸载干净
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    9 小时前
  • 签到天数: 2814 天

    连续签到: 2 天

    [LV.Master]测试大本营

    4#
    发表于 2021-9-3 15:32:04 | 只看该作者
    要不就是安装的有问题,有不就是环境缺少内容
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-19 17:29 , Processed in 0.062467 second(s), 21 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表