Skip to content

Commit

Permalink
Attach extras to allure in the same order they are attached to pytest…
Browse files Browse the repository at this point in the history
…-html
  • Loading branch information
harmin-parra authored Nov 13, 2023
1 parent ae27987 commit febbbff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pytest_webtest_extras/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def save_screenshot(self, image: Union[bytes, str], comment=None, source=None, e
# Add extras to Allure report
if self._fx_allure:
import allure
# Attach the comment
if comment is not None and self._fx_comments:
allure.attach(comment, name=f"comment-{index}", attachment_type=allure.attachment_type.TEXT)
# Attach the image
filename = f"image-{index}"
# Was there an error taking the screenshot?
if "error.png" in link_image:
Expand All @@ -72,8 +76,7 @@ def save_screenshot(self, image: Union[bytes, str], comment=None, source=None, e
image = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="
image = base64.b64decode(image.encode())
allure.attach(image, name=filename, attachment_type=allure.attachment_type.PNG)
if comment is not None and self._fx_comments:
allure.attach(comment, name=f"comment-{index}", attachment_type=allure.attachment_type.TEXT)
# Attach the webpage source
if source is not None:
allure.attach(source, name=f"source-{index}", attachment_type=allure.attachment_type.TEXT)

Expand Down

0 comments on commit febbbff

Please sign in to comment.