A plugin to deselect pytests tests rather than using skipif
Project description
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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_deselect_if-0.1.2.tar.gz.
File metadata
- Download URL: pytest_deselect_if-0.1.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c6641f16761c426b568a7f43c2f2e61dca67c416bc19fcfdd369cc22530529f
|
|
| MD5 |
23c17a40ccb8c412f9a76f96b94b654d
|
|
| BLAKE2b-256 |
1bed2b4670bd8965c65a87a16519f24396d684bcffbf02bbe6a28e68fc3771e0
|
Provenance
The following attestation bundles were made for pytest_deselect_if-0.1.2.tar.gz:
Publisher:
release.yml on jasongi/pytest-deselect-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_deselect_if-0.1.2.tar.gz -
Subject digest:
9c6641f16761c426b568a7f43c2f2e61dca67c416bc19fcfdd369cc22530529f - Sigstore transparency entry: 157708351
- Sigstore integration time:
-
Permalink:
jasongi/pytest-deselect-if@d7e474bf63ecf86ef35930a259c678c267e3a386 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/jasongi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d7e474bf63ecf86ef35930a259c678c267e3a386 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_deselect_if-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pytest_deselect_if-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31d62413cf29f2025f3c39137adc4c6607521160651297dee38e7893da520976
|
|
| MD5 |
8dd194f88c1b5f56512d6164c8b3d93d
|
|
| BLAKE2b-256 |
3e298ef7210dd057e474a1cb2dc021d65bc1f3e5c2c80fd390804fa6f6a3459c
|
Provenance
The following attestation bundles were made for pytest_deselect_if-0.1.2-py3-none-any.whl:
Publisher:
release.yml on jasongi/pytest-deselect-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_deselect_if-0.1.2-py3-none-any.whl -
Subject digest:
31d62413cf29f2025f3c39137adc4c6607521160651297dee38e7893da520976 - Sigstore transparency entry: 157708352
- Sigstore integration time:
-
Permalink:
jasongi/pytest-deselect-if@d7e474bf63ecf86ef35930a259c678c267e3a386 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/jasongi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d7e474bf63ecf86ef35930a259c678c267e3a386 -
Trigger Event:
release
-
Statement type: