Skip to main content

A plugin to uncollect pytests tests rather than using skipif

Project description

PyPI version Python versions See Build Status on GitHub Actions

A pytest plugin to uncollect tests based on a condition without the tests being included in the skipped for deselected report counts. This makes it easier use the Cartesian product of two different usages of pytest.mark.parametrize where you want to disable a specific combination.

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

Requirements

  • pytest > 6.2.0

For development requirements, run

pip install -r requirements-dev.txt

Installation

You can install “pytest-uncollect-if” via pip from PyPI

pip install pytest-uncollect-if

If you do not have autoload enabled, add the plugin to your top-level conftest.py

pytest_plugins = ("pytest_uncollect_if.plugin",)

Usage

The marker takes a single argument func which accepts parameters as **kwargs and returns a boolean value. If the return value is True, the test will be uncollected. To avoid fragile statements that fail on extra parameters, be sure to add **kwargs to your function signature.

param1_decorator = pytest.mark.parametrize("param1", [1, 2, 3, 4])
param2_decorator = pytest.mark.parametrize("param2", [1, 2, 3, 4])


# uncollect if param and param2 are equal
@pytest.mark.uncollect_if(func=lambda param1, param2, **kwargs: param1 == param2)
def test_uncollect_if(param1, param2):
    assert param != param2

A typed alias for pytest.mark.uncollect_if is available as uncollect_if

from pytest_uncollect_if import uncollect_if

param1_decorator = pytest.mark.parametrize("param1", [1, 2, 3, 4])
param2_decorator = pytest.mark.parametrize("param2", [1, 2, 3, 4])


# uncollect if param and param2 are equal
@uncollect_if(func=lambda param1, param2, **kwargs: param1 == param2)
def test_uncollect_if(param1, param2):
    assert param != param2

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, “pytest-uncollect-if” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_uncollect_if-0.1.3.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_uncollect_if-0.1.3-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_uncollect_if-0.1.3.tar.gz.

File metadata

  • Download URL: pytest_uncollect_if-0.1.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pytest_uncollect_if-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2a003f7a0ddfa90b453ff56eb2157aebea16c64a94e5213fcd5676d2461ebe91
MD5 128d8525539e49bc57f5744dd037d437
BLAKE2b-256 ad47f9b9641e356a60bf9907d4e96137dc1f1af5224a53cd03848f42c176a307

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_uncollect_if-0.1.3.tar.gz:

Publisher: release.yml on jasongi/pytest-uncollect-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_uncollect_if-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_uncollect_if-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 60846be537b7080592f496dcfaae135a3c38faf6a48e51c064090d80a559c388
MD5 6f72688ff4ddb5580461ebf42040cdd6
BLAKE2b-256 a11d7c9fa37888ed538d8f9b54c197f1c30566f7db75e6f5d3ba768e7c23537e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_uncollect_if-0.1.3-py3-none-any.whl:

Publisher: release.yml on jasongi/pytest-uncollect-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page