Skip to content

Commit

Permalink
add attachment to a allure report for allure-pytest-bdd (via allure-f…
Browse files Browse the repository at this point in the history
  • Loading branch information
fundakol authored Feb 24, 2020
1 parent 4255c5c commit 7eb32e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions allure-pytest-bdd/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def pytest_configure(config):

pytest_bdd_listener = PytestBDDListener()
config.pluginmanager.register(pytest_bdd_listener)
allure_commons.plugin_manager.register(pytest_bdd_listener)
config.add_cleanup(cleanup_factory(pytest_bdd_listener))

file_logger = AllureFileLogger(report_dir, clean)
allure_commons.plugin_manager.register(file_logger)
Expand Down
10 changes: 10 additions & 0 deletions allure-pytest-bdd/src/pytest_bdd_listener.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import allure_commons
from allure_commons.utils import now
from allure_commons.utils import uuid4
from allure_commons.model2 import Label
from allure_commons.model2 import Status

Expand Down Expand Up @@ -110,3 +112,11 @@ def pytest_runtest_makereport(self, item, call):

if report.when == 'teardown':
self.lifecycle.write_test_case(uuid=uuid)

@allure_commons.hookimpl
def attach_data(self, body, name, attachment_type, extension):
self.lifecycle.attach_data(uuid4(), body, name=name, attachment_type=attachment_type, extension=extension)

@allure_commons.hookimpl
def attach_file(self, source, name, attachment_type, extension):
self.lifecycle.attach_file(uuid4(), source, name=name, attachment_type=attachment_type, extension=extension)

0 comments on commit 7eb32e5

Please sign in to comment.