Skip to content

Commit 50cb0ec

Browse files
authored
fix history for pytest-bdd (via #579)
1 parent 9b0cde4 commit 50cb0ec

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

allure-pytest-bdd/features/scenario.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ Feature: Scenario
2929
When run pytest-bdd with allure
3030
Then allure report has result for "Simple passed example" scenario
3131
Then this scenario has passed status
32+
Then this scenario has a history id

allure-pytest-bdd/src/pytest_bdd_listener.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from allure_commons.types import LabelType
99
from allure_commons.utils import platform_label
1010
from allure_commons.utils import host_tag, thread_tag
11+
from allure_commons.utils import md5
1112
from .utils import get_uuid
1213
from .utils import get_step_name
1314
from .utils import get_status_details
@@ -41,6 +42,7 @@ def pytest_bdd_before_scenario(self, request, feature, scenario):
4142
test_result.fullName = full_name
4243
test_result.name = name
4344
test_result.start = now()
45+
test_result.historyId = md5(request.node.nodeid)
4446
test_result.labels.append(Label(name=LabelType.HOST, value=self.host))
4547
test_result.labels.append(Label(name=LabelType.THREAD, value=self.thread))
4648
test_result.labels.append(Label(name=LabelType.FRAMEWORK, value="pytest-bdd"))

allure-pytest-bdd/test/steps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from allure_commons_test.result import has_step
99
# from allure_commons_test.result import has_attachment
1010
from allure_commons_test.result import has_parameter
11+
from allure_commons_test.result import has_history_id
1112
# from allure_commons_test.result import has_status_details
1213
# from allure_commons_test.result import with_message_contains
1314
# from allure_commons_test.result import has_link
@@ -42,6 +43,13 @@ def item_status(allure_report, context, item, status):
4243
assert_that(allure_report, matcher())
4344

4445

46+
@then(parsers.parse("this {item:w} has a history id"))
47+
def item_history_id(allure_report, context, item):
48+
context_matcher = context[item]
49+
matcher = partial(context_matcher, has_history_id)
50+
assert_that(allure_report, matcher())
51+
52+
4553
@then(parsers.re("this (?P<item>\\w+) "
4654
"has parameter (?:\")(?P<param_name>[\\w|\\s]*)(?:\") "
4755
"with value (?:\")(?P<param_value>[\\w|\\s]*)(?:\")"))

0 commit comments

Comments
 (0)