Skip to content
Closed
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
17 changes: 12 additions & 5 deletions allure-pytest/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions tests/allure_pytest/acceptance/label/tag/tag_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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')")
Expand Down