Skip to content

Commit c217262

Browse files
authored
fixed that not closed fixture step breaks location of next body steps (via #568)
1 parent 44669ed commit c217262

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

allure-pytest/src/listener.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def pytest_runtest_call(self, item):
100100
uuid = self._cache.get(item.nodeid)
101101
test_result = self.allure_logger.get_test(uuid)
102102
if test_result:
103+
self.allure_logger.drop_test(uuid)
104+
self.allure_logger.schedule_test(uuid, test_result)
103105
test_result.start = now()
104106
yield
105107
if test_result:

allure-pytest/test/acceptance/fixture/yield_fixture_test.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import allure
2-
from hamcrest import assert_that
3-
from allure_commons_test.report import has_test_case
4-
from allure_commons_test.container import has_container
52
from allure_commons_test.container import has_before
3+
from allure_commons_test.container import has_container
4+
from allure_commons_test.report import has_test_case
5+
from allure_commons_test.result import has_step
6+
from hamcrest import assert_that, not_, all_of
67

78

89
@allure.feature("Fixture")
@@ -25,3 +26,39 @@ def test_yield_fixture(executed_docstring_source):
2526
),
2627
)
2728
)
29+
30+
31+
def test_opened_step_function(executed_docstring_source):
32+
"""
33+
>>> import allure
34+
>>> import pytest
35+
36+
>>> @pytest.fixture()
37+
... def yield_fixture():
38+
... with allure.step("Opened step"):
39+
... yield
40+
41+
>>> def test_opened_step(yield_fixture):
42+
... with allure.step("Body step"):
43+
... pass
44+
"""
45+
46+
assert_that(
47+
executed_docstring_source.allure_report,
48+
has_test_case(
49+
"test_opened_step",
50+
all_of(
51+
has_step("Body step"),
52+
has_container(
53+
executed_docstring_source.allure_report,
54+
has_before(
55+
"yield_fixture",
56+
has_step(
57+
"Opened step",
58+
not_(has_step("Body step"))
59+
)
60+
)
61+
),
62+
)
63+
)
64+
)

0 commit comments

Comments
 (0)