Skip to content
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

Support for fixture values in test titles for pytest #530

Merged
merged 2 commits into from Dec 6, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion allure-pytest/src/utils.py
Expand Up @@ -109,7 +109,7 @@ def allure_package(item):
def allure_name(item, parameters):
name = escape_name(item.name)
title = allure_title(item)
return title.format(**parameters) if title else name
return title.format(**{**parameters, **item.funcargs}) if title else name


def allure_full_name(item):
Expand Down
21 changes: 21 additions & 0 deletions allure-pytest/test/acceptance/display_name/display_name_test.py
Expand Up @@ -52,3 +52,24 @@ def test_unicode_display_name_template(executed_docstring_source):
has_title(u"Тест с шаблоном и параметром: False")
)
)


def test_fixture_value_in_display_name(executed_docstring_source):
"""
>>> import allure
>>> import pytest
>>> @pytest.fixture
... def fix():
... return 'fixture value'
>>> @allure.title('title with {fix}')
... def test_fixture_value_name(fix):
... pass
"""

assert_that(executed_docstring_source.allure_report,
has_test_case("test_fixture_value_name",
has_title("title with fixture value")
)
)