Skip to content

Commit 7eb32e5

Browse files
authored
add attachment to a allure report for allure-pytest-bdd (via #469)
1 parent 4255c5c commit 7eb32e5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

allure-pytest-bdd/src/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def pytest_configure(config):
3434

3535
pytest_bdd_listener = PytestBDDListener()
3636
config.pluginmanager.register(pytest_bdd_listener)
37+
allure_commons.plugin_manager.register(pytest_bdd_listener)
38+
config.add_cleanup(cleanup_factory(pytest_bdd_listener))
3739

3840
file_logger = AllureFileLogger(report_dir, clean)
3941
allure_commons.plugin_manager.register(file_logger)

allure-pytest-bdd/src/pytest_bdd_listener.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
2+
import allure_commons
23
from allure_commons.utils import now
4+
from allure_commons.utils import uuid4
35
from allure_commons.model2 import Label
46
from allure_commons.model2 import Status
57

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

111113
if report.when == 'teardown':
112114
self.lifecycle.write_test_case(uuid=uuid)
115+
116+
@allure_commons.hookimpl
117+
def attach_data(self, body, name, attachment_type, extension):
118+
self.lifecycle.attach_data(uuid4(), body, name=name, attachment_type=attachment_type, extension=extension)
119+
120+
@allure_commons.hookimpl
121+
def attach_file(self, source, name, attachment_type, extension):
122+
self.lifecycle.attach_file(uuid4(), source, name=name, attachment_type=attachment_type, extension=extension)

0 commit comments

Comments
 (0)