Skip to content

Fix missing fixtures in report when using lazy_fixture #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions allure-pytest/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def _test_fixtures(item):
fixturemanager = item.session._fixturemanager
fixturedefs = []

if hasattr(item, "fixturenames"):
for name in item.fixturenames:
if hasattr(item._request, "fixturenames"):
for name in item._request.fixturenames:
fixturedef = fixturemanager.getfixturedefs(name, item.nodeid)
if fixturedef:
fixturedefs.append(fixturedef[-1])
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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


@allure.feature("Integration")
def test_lazy_fixture(executed_docstring_source):
"""
>>> import pytest
... from pytest_lazyfixture import lazy_fixture

>>> @pytest.fixture
... def my_lazy_fixture():
... pass

>>> @pytest.mark.parametrize('param', [lazy_fixture('my_lazy_fixture')])
... def test_lazy_fixture_example(param):
... pass
"""

assert_that(executed_docstring_source.allure_report,
has_test_case("test_lazy_fixture_example",
has_container(executed_docstring_source.allure_report,
has_before("my_lazy_fixture")
),
)
)


@allure.feature("Integration")
def test_nested_lazy_fixture(executed_docstring_source):
"""
>>> import pytest
... from pytest_lazyfixture import lazy_fixture

>>> @pytest.fixture
... def my_lazy_fixture():
... pass

>>> @pytest.fixture(params=[lazy_fixture('my_lazy_fixture')])
... def my_ordinary_fixture():
... pass

>>> def test_nested_lazy_fixture_example(my_ordinary_fixture):
... pass
"""

assert_that(executed_docstring_source.allure_report,
has_test_case("test_nested_lazy_fixture_example",
has_container(executed_docstring_source.allure_report,
has_before("my_lazy_fixture")
),
)
)
1 change: 1 addition & 0 deletions allure-pytest/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ deps =
pytest-flakes
pytest-rerunfailures
pytest-xdist
pytest-lazy-fixture
mock
{distshare}/allure-python-commons-2*.zip
{distshare}/allure-python-commons-test-2*.zip
Expand Down