A pytest plugin to deselect tests based on a condition without the tests being included in the skipped report count. This makes it easier use the Cartesian product of two different usages of pytest.mark.parametrize where you want to disable a specific combination. Based off the implementation in this pytest issue comment.
If you don’t want the tests to be included in the test count at all, check out the pytest-uncollect-if plugin which will remove the tests silently without them appearing in skipped, collected or deselected.
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-deselect-if” via pip from PyPI
pip install pytest-deselect-if
If you do not have autoload enabled, add the plugin to your top-level conftest.py
pytest_plugins = ("pytest_deselect_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 deselected.
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])
# deselect if param and param2 are equal
@pytest.mark.deselect_if(func=lambda param1, param2, **kwargs: param1 == param2)
def test_deselect_if(param1, param2):
assert param != param2
A typed alias for pytest.mark.deselect_if is available as deselect_if
from pytest_deselect_if import deselect_if
param1_decorator = pytest.mark.parametrize("param1", [1, 2, 3, 4])
param2_decorator = pytest.mark.parametrize("param2", [1, 2, 3, 4])
# deselect if param and param2 are equal
@deselect_if(func=lambda param1, param2, **kwargs: param1 == param2)
def test_deselect_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-deselect-if” is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Metadata
Release files for pytest-deselect-if 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_deselect_if-0.1.3.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_deselect_if-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / pytest_deselect_if-0.1.3.tar.gz
| Download URL | pytest_deselect_if-0.1.3.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4ca615d8fffd024ce0be6ab89543a1ecf519353b82126525b865fdfeefa88f0
|
|
BLAKE2b-256 checksum How to use checksums |
714f5f10dc11a487b5af9affcca06649e109f80c8162bca9ab207e58d8fb192b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / pytest_deselect_if-0.1.3-py3-none-any.whl
| Download URL | pytest_deselect_if-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c219e705c4aa445a32affbb784e1d3d02f0a97dbbf129f61882946260d1e875e
|
|
BLAKE2b-256 checksum How to use checksums |
30bc1fe068ce1ef2dbacb47fc0e1c2a96d80a012dfa78bee797840593a119292
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency log