【问题标题】:module 'pytest' has no attribute 'allure'模块 'pytest' 没有属性 'allure'
【发布时间】:2021-10-13 08:51:56
【问题描述】:

我收到错误“AttributeError: module 'pytest' has no attribute 'allure' in the following code

def take_screenshots(txt):

file_name = "{}.png".format(Communication.get_random_characters())

Settings.get_driver().get_screenshot_as_file(file_name)
    pytest.allure.attach.file(file_name,name=txt,attachment_type=pytest.allure.attachment_type.PNG)

E AttributeError: 模块 'pytest' 没有属性 'allure'

我在项目中使用以下插件,python 版本是最新的:3.9.7

pytest-allure=2.9.44
allure-python-commons=2.9.44
apipkg==2.0.1
attrs==21.2.0
certifi==2021.10.8
chardet==4.0.0
colorama==0.4.4
enum34==1.1.10
execnet==1.9.0
idna==3.2
lxml==4.6.3
namedlist==1.8
pluggy==1.0.0
py==1.8.2
pytest==6.2.5
pytest-forked==1.3.0
pytest-xdist==2.3.0
python-guerrillamail==0.2.0
requests==2.26.0
selenium==3.141.0
six==1.16.0
urllib3==1.26.7
imaplib2==3.6
paramiko==2.7.2
pandas==1.3.3
xlrd==2.0.1
cryptography==35.0.0
beautifulsoup4==4.10.0
bs4==0.0.1
pytest-timeout==1.4.2
xmltodict==0.12.0

谁能帮我解决这个问题?

【问题讨论】:

    标签: python selenium allure


    【解决方案1】:

    我想你还没有安装Allure-pytest 包。您必须使用以下命令将其安装到您的项目中。

    pip install allure-pytest
    

    【讨论】:

    • 感谢您的建议。但是在我的项目中安装了“allure-pytest”之后。我仍然遇到同样的错误。
    • 我已经删除了 pytest。从“pytest.allure.attach.file”开始工作。由于 pytest 命名空间弃用,这似乎是个问题。
    猜你喜欢
    • 1970-01-01
    • 2023-02-26
    • 1970-01-01
    • 1970-01-01
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 2020-06-04
    • 2021-12-24
    相关资源
    最近更新 更多