Skip to content

Commit

Permalink
fixed that not closed fixture step breaks location of next body steps…
Browse files Browse the repository at this point in the history
… (via #568)
  • Loading branch information
skhomuti authored Mar 3, 2021
1 parent 44669ed commit c217262
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
2 changes: 2 additions & 0 deletions allure-pytest/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def pytest_runtest_call(self, item):
uuid = self._cache.get(item.nodeid)
test_result = self.allure_logger.get_test(uuid)
if test_result:
self.allure_logger.drop_test(uuid)
self.allure_logger.schedule_test(uuid, test_result)
test_result.start = now()
yield
if test_result:
Expand Down
43 changes: 40 additions & 3 deletions allure-pytest/test/acceptance/fixture/yield_fixture_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import allure
from hamcrest import assert_that
from allure_commons_test.report import has_test_case
from allure_commons_test.container import has_container
from allure_commons_test.container import has_before
from allure_commons_test.container import has_container
from allure_commons_test.report import has_test_case
from allure_commons_test.result import has_step
from hamcrest import assert_that, not_, all_of


@allure.feature("Fixture")
Expand All @@ -25,3 +26,39 @@ def test_yield_fixture(executed_docstring_source):
),
)
)


def test_opened_step_function(executed_docstring_source):
"""
>>> import allure
>>> import pytest
>>> @pytest.fixture()
... def yield_fixture():
... with allure.step("Opened step"):
... yield
>>> def test_opened_step(yield_fixture):
... with allure.step("Body step"):
... pass
"""

assert_that(
executed_docstring_source.allure_report,
has_test_case(
"test_opened_step",
all_of(
has_step("Body step"),
has_container(
executed_docstring_source.allure_report,
has_before(
"yield_fixture",
has_step(
"Opened step",
not_(has_step("Body step"))
)
)
),
)
)
)

0 comments on commit c217262

Please sign in to comment.