Skip to main content

Build Status PyPI version Python Version Code style License

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

pytest-tagging-screenshot

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

Metadata

Release files for pytest_tagging 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest_tagging 1.6.0
File Size Uploaded
pytest_tagging-1.6.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest_tagging 1.6.0
File Interpreter ABI Platform
pytest_tagging-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / pytest_tagging-1.6.0.tar.gz

Download URL pytest_tagging-1.6.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
950ab148a27f688a322cde656248cdcb97d75f88f0b91e26312c2e005ec9dab2
BLAKE2b-256 checksum
How to use checksums
646f04cf9f808df000e76e8b86045d86b0972b3b72e92c991bf61e85279bd9d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.10.2 Linux/6.5.0-1025-azure

Release files / pytest_tagging-1.6.0-py3-none-any.whl

Download URL pytest_tagging-1.6.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b6ba4053b226a4911a749ecdc2dacce04337d2748682a5cb6bbcec3a401be1c
BLAKE2b-256 checksum
How to use checksums
6804e7d37635b8d1a835a45e741fbdbe9708e1cc62329ee2e61cb871f81d7b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.10.2 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page