A plugin to uncollect pytests tests rather than using skipif
Project description
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
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
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-uncollect-if-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f562685a6531e022d3591eff2d9ce3cc4a55a1f22d7d68ec6d76213782c1c1 |
|
MD5 | 7695acdde9b81d03cf584d6abcccaa3e |
|
BLAKE2b-256 | 1362ead89d67a7013cdb18bb8eb4ee05ddc543b10fcfd197574cd71f6cbb8409 |
Hashes for pytest_uncollect_if-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53f4afcc7f723f35018cf3c3713bfc4bdb184858ae1c4057ee574c673ece9156 |
|
MD5 | 701cc7760afeb072888a4641b4fff24a |
|
BLAKE2b-256 | bf7c7b10b019d17462e9bde2ad8e31ff8be9a4b116d6bd918c79b5111b754782 |