Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluding allure-labels in pytest run #812

Open
1 task
ushankax opened this issue May 3, 2024 · 1 comment
Open
1 task

Excluding allure-labels in pytest run #812

ushankax opened this issue May 3, 2024 · 1 comment
Labels
task:new feature Requesting new capability or software feature theme:pytest

Comments

@ushankax
Copy link

ushankax commented May 3, 2024

I'm submitting a ...

  • feature request

What is the current behavior?

We have CLI param --allure-label and its possible to INCLUDE labels. Like --allure-label method=AnyMethod and it works

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

But I decided to try to exclude from run tests with @allure.manual(True) decorator and came across a bunch of things:

  1. You can't even include by label if your value (but it's default value) is a bool type. Example: if you set --allure-label ALLURE_MANUAL=True in CLI so it will deselect everything.
  2. But I could find an interesting moment: if to write decorator like @allure.manual('True') and set the same --allure-label ALLURE_MANUAL=True in CLI -- it works and manual tests will be selected.

What is the expected behavior?

I want not just include labels, but also exclude. Something like --allure-label "not ALLURE_MANUAL=True"

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

We write tests as code and we dont need manual test cases in allure report. With this feature we will be able to run night tests and they will be closed automatically in allure testOps.

Please tell us about your environment:

  • Allure version: 4.22.1
  • Test framework: pytest==7.2.2
  • Allure adaptor: allure-pytest==2.13.2
@delatrie delatrie added theme:pytest task:new feature Requesting new capability or software feature labels May 23, 2024
@delatrie
Copy link
Contributor

Hi, @ushankax. Thank you for the feature request. That's something that might be implemented in the future. Sorry for not giving any specific date.

That said, it's much quicker to implement such specific filtering in your own code. Just put the following in your conftest.py:

from allure_commons.types import LabelType
from allure_pytest.utils import allure_label

def pytest_addoption(parser):
    parser.addoption('--exclude-manual', action='store_true')

def pytest_collection_modifyitems(config, items):
    if config.getoption("--exclude-manual"):
        items[:] = filter(
            lambda item: not any(allure_label(item, LabelType.MANUAL)),
            items,
        )

Then, exclude manual tests by invoking pytest --exclude-manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task:new feature Requesting new capability or software feature theme:pytest
Projects
None yet
Development

No branches or pull requests

2 participants