pytest-deselect-if

A plugin to deselect pytests tests rather than using skipif


License
Other
Install
pip install pytest-deselect-if==0.1.1

Documentation

pytest-deselect-if

PyPI version

Python versions

See Build Status on GitHub Actions


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

Installation

You can install "pytest-deselect-if" via pip from PyPI

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

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.

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

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.