Skip to content

Commit

Permalink
support for fixture values in test titles (via allure-framework#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Ryabkov authored and GilBecker-Anaplan committed Apr 10, 2023
1 parent 22ee377 commit 050f958
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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")
)
)

0 comments on commit 050f958

Please sign in to comment.