pytest plugin that allows tagging tests using arbitrary strings.
It supports selecting only tests with a specific tag, and displays a counter of how many tests failed for each specific tag.
This package exists because doing all of this with pytest.mark is painful, since it requires registering marks,
and you cannot use variables defined elsewhere easily.
@pytest.mark.tags("JIRA-XX", "integration", constants.COMPONENT_X)
def test_foo():
assert FalseInvocation:
pytest --tags integration --tags MY_COMPONENT_NAMEBy default, all tests that match at least one tag will be collected. To only select tests that have all the provided tags, use the option --tags-operand=AND, like so:
pytest --tags integration --tags MY_COMPONENT_NAME --tags-operand ANDYou can also display all available tags by specifying --tags empty:
pytest --tags
>>Available tags:
>>foo
>>barTags can be combined using pytest_tagging.combine_tags:
from pytest_tagging import combine_tags
combine_tags("all", "foo", "bar")Then you can execute pytest --tags all and it will run all tests with foo and bar tags
You can exclude tags for a particular test run by using the option --exclude-tags in a similar
way to the --tags option. Notice tests with tags that are excluded will not be executed, even if
they contain a tag that was selected with --tags.
pytest --tags mobile --tags web --exclude-tags flaky- It is thread-safe, so it can be used with pytest-parallel.
