Skip to content

Commit

Permalink
No need to update fixtures in test teardown because all fixtures are …
Browse files Browse the repository at this point in the history
…already finished at this moment and no way to run they again (#696)
  • Loading branch information
skhomuti committed Oct 12, 2022
1 parent 2e869c7 commit d0415af
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
1 change: 0 additions & 1 deletion allure-pytest/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def pytest_runtest_call(self, item):
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_teardown(self, item):
yield
self._update_fixtures_children(item)
uuid = self._cache.get(item.nodeid)
test_result = self.allure_logger.get_test(uuid)
test_result.labels.extend([Label(name=name, value=value) for name, value in allure_labels(item)])
Expand Down
39 changes: 39 additions & 0 deletions allure-pytest/test/acceptance/fixture/fixture_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,42 @@ def test_three(request):
)
)
)


def test_one_fixture_on_two_tests(allured_testdir):
allured_testdir.testdir.makepyfile("""
import pytest
import allure
@pytest.fixture
def fixture(request):
with allure.step(request.node.name):
pass
class TestClass:
def test_first(self, fixture):
pass
def test_second(self, fixture):
pass
""")
allured_testdir.run_with_allure()

assert_that(allured_testdir.allure_report,
has_test_case("test_first",
has_container(allured_testdir.allure_report,
has_before("fixture", has_step("test_first")),
),
not_(has_container(allured_testdir.allure_report,
has_before("fixture", has_step("test_second")),
))
),
has_test_case("test_second",
has_container(allured_testdir.allure_report,
has_before("fixture", has_step("test_second")),
),
not_(has_container(allured_testdir.allure_report,
has_before("fixture", has_step("test_first")),
))
)
)

0 comments on commit d0415af

Please sign in to comment.