Skip to content

Commit 24e19b5

Browse files
skhomutiGilBecker-Anaplan
authored andcommitted
No need to update fixtures in test teardown because all fixtures are already finished at this moment and no way to run they again (allure-framework#696)
1 parent 0ef9741 commit 24e19b5

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

allure-pytest/src/listener.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def pytest_runtest_call(self, item):
115115
@pytest.hookimpl(hookwrapper=True)
116116
def pytest_runtest_teardown(self, item):
117117
yield
118-
self._update_fixtures_children(item)
119118
uuid = self._cache.get(item.nodeid)
120119
test_result = self.allure_logger.get_test(uuid)
121120
test_result.labels.extend([Label(name=name, value=value) for name, value in allure_labels(item)])

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,42 @@ def test_three(request):
372372
)
373373
)
374374
)
375+
376+
377+
def test_one_fixture_on_two_tests(allured_testdir):
378+
allured_testdir.testdir.makepyfile("""
379+
import pytest
380+
import allure
381+
382+
@pytest.fixture
383+
def fixture(request):
384+
with allure.step(request.node.name):
385+
pass
386+
387+
class TestClass:
388+
def test_first(self, fixture):
389+
pass
390+
391+
def test_second(self, fixture):
392+
pass
393+
""")
394+
allured_testdir.run_with_allure()
395+
396+
assert_that(allured_testdir.allure_report,
397+
has_test_case("test_first",
398+
has_container(allured_testdir.allure_report,
399+
has_before("fixture", has_step("test_first")),
400+
),
401+
not_(has_container(allured_testdir.allure_report,
402+
has_before("fixture", has_step("test_second")),
403+
))
404+
),
405+
has_test_case("test_second",
406+
has_container(allured_testdir.allure_report,
407+
has_before("fixture", has_step("test_second")),
408+
),
409+
not_(has_container(allured_testdir.allure_report,
410+
has_before("fixture", has_step("test_first")),
411+
))
412+
)
413+
)

0 commit comments

Comments
 (0)