From e400a8adc52b67e4c4b5c96c038ec3a3744b4273 Mon Sep 17 00:00:00 2001 From: sharovd Date: Sat, 5 Apr 2025 14:38:55 +0400 Subject: [PATCH] fix: support the display of duplicate tag names (#832) --- allure-pytest/src/utils.py | 17 ++++++++++++----- .../acceptance/label/tag/tag_test.py | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/allure-pytest/src/utils.py b/allure-pytest/src/utils.py index 1e07cb49..b744f500 100644 --- a/allure-pytest/src/utils.py +++ b/allure-pytest/src/utils.py @@ -81,14 +81,21 @@ def format_allure_link(config, url, link_type): def pytest_markers(item): + markers = set() + builtin_markers = set() for keyword in item.keywords.keys(): if any([keyword.startswith('allure_'), keyword == 'parametrize']): continue - marker = item.get_closest_marker(keyword) - if marker is None: - continue - - yield mark_to_str(marker) + for marker in item.iter_markers(name=keyword): + mark_str = mark_to_str(marker) + is_builtin_mark = mark_str.startswith("@pytest.mark.") + if is_builtin_mark: + if marker.name in builtin_markers: + continue + builtin_markers.add(marker.name) + if mark_str not in markers: + markers.add(mark_str) + yield mark_str def mark_to_str(marker): diff --git a/tests/allure_pytest/acceptance/label/tag/tag_test.py b/tests/allure_pytest/acceptance/label/tag/tag_test.py index 3f32475b..f444ed97 100644 --- a/tests/allure_pytest/acceptance/label/tag/tag_test.py +++ b/tests/allure_pytest/acceptance/label/tag/tag_test.py @@ -35,6 +35,8 @@ def test_show_reserved_pytest_markers_full_decorator( >>> @pytest.mark.usermark1 ... @pytest.mark.usermark2 + ... @pytest.mark.usermark3("comment1") + ... @pytest.mark.usermark3("comment2") ... @pytest.mark.parametrize("param", ["foo"]) ... @pytest.mark.skipif(False, reason="reason2") ... @pytest.mark.skipif(False, reason="reason1") @@ -50,6 +52,8 @@ def test_show_reserved_pytest_markers_full_decorator( "test_show_reserved_pytest_markers_full_decorator_example[foo]", has_tag("usermark1"), has_tag("usermark2"), + has_tag("usermark3('comment1')"), + has_tag("usermark3('comment2')"), has_tag("@pytest.mark.skipif(False, reason='reason1')"), not_( has_tag("@pytest.mark.skipif(False, reason='reason2')")