GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allure report's tags support the display of duplicate tag names · Issue #832 · allure-framework/allure-python

Allure report's tags support the display of duplicate tag names #832

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Allure report's tags support the display of duplicate tag names#832
Copy link
Labels
theme:pytest

Description

@tdxs8848
tdxs8848
opened on Nov 12, 2024
Issue body actions

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

I marked multiple marks with the same name in the use case

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

    @pytest.mark.case_id("TC-002")
    @pytest.mark.case_id("TC-003")
    @pytest.mark.case_id("TC-001")
    def test_mark(self):
        ...

What is the expected behavior?

Display multiple tags for all

What is the motivation / use case for changing the behavior?

Display tags correctly

Please tell us about your environment:

  • Allure version: 2.13.8
  • Test framework: [email protected]
  • Allure adaptor: [email protected]

Other information

I noticed that the function item.get_closest_marker(name) to process markers is called in allure. For multiple marks with the same name, only return the first marker matching the name

file allure_pytest\utils.py 83 line
def pytest_markers(item):
    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)

you should probably call the function item.iter_markers(name)

Activity

  1. delatrie
    added
    bugSomething isn't workingSomething isn't working
    theme:pytest
    on Apr 1, 2025
  2. delatrie
    added the
    Bug
    issue type on Apr 1, 2025
  3. sharovd
    added a commit that references this issue on Apr 5, 2025

    fix: support the display of duplicate tag names (allure-framework#832)

    b90428c
  4. sharovd commented on Apr 5, 2025

    @sharovd
    sharovd
    on Apr 5, 2025
    Contributor
    More actions

    @delatrie, hi! I noticed you labeled this issue as a bug, and I’ve tried to fix it in my PR.
    @tdxs8848, thank you for the detailed issue description — I hope we’ll be able to get this resolved!

  5. delatrie commented on Apr 22, 2025

    @delatrie
    delatrie
    on Apr 22, 2025
    Contributor
    More actions

    This is surely a bug from the current implementation standpoint. But I would like to revisit this feature as a whole. I always felt we're doing too much here converting markers that don't really match Allure tags. That includes converting built-in markers and markers with arguments (like the ones shown by OP).

    Built-in markers (skipif, usefixtures, etc) are not used to tag tests, and we have other means to indicate their effect (the set up/tear down sections, status, details/trace). I think we should ignore not only parametrize but also the rest of them.

    As for user-defined markers with arguments, we currently compress them into something like foo('bar', baz='qux'), but is it really a good way to tag a test? In many cases those can't be used in Allure's filters (because of spaces) and end up with just polluting the test results and taking extra disk space (imagine stuff like foo(<test.welcome_test.MyClass object at 0x104716ee0>) in the list of tags for each test you have).

    Furthermore, we don't do anything similar to what we do with pytest markers in other integrations (e.g., we don't convert Playwright annotations to tags in allure-playwright).

    To summarize, we should only convert markers with no arguments, and we should ignore skip, skipif, xfail, parametrize, usefixtures, and filterwarnings. This is how it was recently implemented in allure-pytest-bdd, and I believe this is much closer to what tags should really be.

    Other user-specific cases like the one in this issue can be implemented on a per-user basis. In most cases, that will just be a matter of putting some simple code in conftest.py (e.g., a hook or a custom decorator).

    As for the OP's example, given all above, I would compose the case_id marker with allure.tag (which is also a marker under the hood) in something like:

    def case_id(value):
        case_id_marker = pytest.mark.case_id(value)
        allure_tag_marker = allure.tag(value)
        return lambda fn: allure_tag_marker(case_id_marker(fn))
    
    @case_id("TC-001")
    @case_id("TC-002")
    @case_id("TC-003")
    def test_mark(self):
            ...

    This will keep the original behavior of @pytest.mark.case_id and apply Allure tags like TC-001 to the results. Such tags are easier to filter in Allure Report (by, e.g., tag:TC-001 in the search bar) and they look better than case_id('TC-001').

    @tdxs8848, will the above solution suit your needs? Given the original @pytest.mark.case_id won't be in tags. If not, could you please describe your use case in more detail: what purpose do Allure tags like case_id('TC-001') serve?

    EDIT: turns out we have an existing issue that addresses what I've described: #817.

  6. delatrie
    removed the
    Bug
    issue type on Apr 22, 2025
  7. delatrie
    removed
    bugSomething isn't workingSomething isn't working
    on Apr 22, 2025
  8. delatrie
    added a commit that references this issue on Apr 24, 2025

    fix: support the display of duplicate tag names (allure-framework#832)

    044db77
  9. sharovd
    added a commit that references this issue on May 16, 2025

    fix: support the display of duplicate tag names (allure-framework#832)

    e400a8a
  10. delatrie commented on Jun 14, 2025

    @delatrie
    delatrie
    on Jun 14, 2025
    Contributor
    More actions

    The marker-to-tag conversion behavior was changed in version 2.14.3. This issue is not relevant anymore. If you still have problems, please feel free to open a new issue or discussion.

  11. delatrie
    closed this as not plannedon Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme:pytest

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.