allure-python icon indicating copy to clipboard operation
allure-python copied to clipboard

module 'pytest' has no attribute 'allure'

Open sudhakar2006 opened this issue 3 years ago • 2 comments

I am getting the error "AttributeError: module 'pytest' has no attribute 'allure' in below place

@staticmethod
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: module 'pytest' has no attribute 'allure'

I am using below plugins for the project and python version is latest one: 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

Can anyone help me to solve this issue?

sudhakar2006 avatar Oct 12 '21 15:10 sudhakar2006

https://github.com/allure-framework/allure-python/blob/master/allure-pytest/examples/attachment/attachment.rst

rad96 avatar Oct 15 '21 13:10 rad96

Thanks rad. It's helpful. I removed pytest from above code and it begins to work.

sudhakar2006 avatar Oct 15 '21 13:10 sudhakar2006