a pytest plugin to tag tests
Project description
pytest-tagging
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.
Usage
@pytest.mark.tags("JIRA-XX", "integration", constants.COMPONENT_X)
def test_foo():
assert False
Invocation:
pytest --tags integration --tags MY_COMPONENT_NAME
By 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 AND
You can also display all available tags by specifying --tags
empty:
pytest --tags
>>Available tags:
>>foo
>>bar
Combining tags
Tags 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
Excluding 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
Extra
- It is thread-safe, so it can be used with pytest-parallel.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_tagging-1.5.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36902b4a1ef19dd382a197198f5b80886a5a2dcd196afd2732952a7b8fdd4df5 |
|
MD5 | 679f7115a50ae2e45a2375e4431de7d4 |
|
BLAKE2b-256 | f2d4bc50547e091dffe510d117f600652c0e2e7e01388fc43df22459bb5a1b97 |