Skip to content

Commit bea7854

Browse files
committed
fix report for dynamically called fixtures
1 parent a7a8aa1 commit bea7854

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

allure-pytest/src/listener.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def pytest_fixture_setup(self, fixturedef, request):
132132
container_uuid = self._cache.push(fixturedef)
133133
container = TestResultContainer(uuid=container_uuid)
134134
self.allure_logger.start_group(container_uuid, container)
135+
self.allure_logger.update_group(container_uuid, children=self._cache.get(request._pyfuncitem.nodeid))
135136

136137
self.allure_logger.update_group(container_uuid, start=now())
137138

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,27 @@ def test_with_redefined_fixture(my_fixture):
272272
),
273273
)
274274
)
275+
276+
277+
def test_dynamically_called_fixture(allured_testdir):
278+
allured_testdir.testdir.makepyfile("""
279+
import pytest
280+
281+
@pytest.fixture
282+
def my_fixture():
283+
yield
284+
285+
def test_fixture_example(request):
286+
request.getfixturevalue('my_fixture')
287+
""")
288+
289+
allured_testdir.run_with_allure()
290+
291+
assert_that(allured_testdir.allure_report,
292+
has_test_case("test_fixture_example",
293+
has_container(allured_testdir.allure_report,
294+
has_before("my_fixture"),
295+
has_after("my_fixture::0"),
296+
),
297+
)
298+
)

0 commit comments

Comments
 (0)