Skip to content

Commit 044db77

Browse files
sharovddelatrie
authored andcommitted
fix: support the display of duplicate tag names (#832)
1 parent 68bbafe commit 044db77

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

allure-pytest/src/utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,21 @@ def format_allure_link(config, url, link_type):
8181

8282

8383
def pytest_markers(item):
84+
markers = set()
85+
builtin_markers = set()
8486
for keyword in item.keywords.keys():
8587
if any([keyword.startswith('allure_'), keyword == 'parametrize']):
8688
continue
87-
marker = item.get_closest_marker(keyword)
88-
if marker is None:
89-
continue
90-
91-
yield mark_to_str(marker)
89+
for marker in item.iter_markers(name=keyword):
90+
mark_str = mark_to_str(marker)
91+
is_builtin_mark = mark_str.startswith("@pytest.mark.")
92+
if is_builtin_mark:
93+
if marker.name in builtin_markers:
94+
continue
95+
builtin_markers.add(marker.name)
96+
if mark_str not in markers:
97+
markers.add(mark_str)
98+
yield mark_str
9299

93100

94101
def mark_to_str(marker):

tests/allure_pytest/acceptance/label/tag/tag_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def test_show_reserved_pytest_markers_full_decorator(
3535
3636
>>> @pytest.mark.usermark1
3737
... @pytest.mark.usermark2
38+
... @pytest.mark.usermark3("comment1")
39+
... @pytest.mark.usermark3("comment2")
3840
... @pytest.mark.parametrize("param", ["foo"])
3941
... @pytest.mark.skipif(False, reason="reason2")
4042
... @pytest.mark.skipif(False, reason="reason1")
@@ -50,6 +52,8 @@ def test_show_reserved_pytest_markers_full_decorator(
5052
"test_show_reserved_pytest_markers_full_decorator_example[foo]",
5153
has_tag("usermark1"),
5254
has_tag("usermark2"),
55+
has_tag("usermark3('comment1')"),
56+
has_tag("usermark3('comment2')"),
5357
has_tag("@pytest.mark.skipif(False, reason='reason1')"),
5458
not_(
5559
has_tag("@pytest.mark.skipif(False, reason='reason2')")

0 commit comments

Comments
 (0)