Skip to main content

Pytest plugin for excluding tests based on coverage data

Project description

https://api.travis-ci.org/mhallin/cov-exclude-py.svg?branch=master https://img.shields.io/pypi/v/cov-exclude.svg

Coverage-based test exclusion plugin for pytest. By looking at which lines are executed by each test, the next test run can be sped up by not executing the tests where no source files have changed.

If you have a large test suite which you often re-run, this plugin can drastically improve the iteration times.

Installation

Install with pip:

$ pip install cov-exclude

cov-exclude requires Pytest 2.8 or later. It is compatible with Python 2.7, 3.3, 3.4, 3.5, as well as PyPy. It does not work on PyPy 3 due to an unknown bug with the coverage data generated.

Usage

The first time you run your test suite, per-test coverage is enabled and the suite will take a little bit longer than usual:

$ py.test

==================== test session starts =====================

# Test output...

================ MANY passed in MANY seconds =================

Now when you re-run the test suite, all tests should have been excluded:

$ py.test

==================== test session starts =====================

# Test output...

=============== MANY deselected in FEW seconds ===============

If a test fails, it will re-run even if nothing changed in order to preserve the general failure status of the test suite.

Forcing individual test inclusion

If you have tests that depend on files not included in coverage data, such as data files or generated sources, you can mark the tests with external_dependencies. This forces them to be re-run even if no files were changed:

@pytest.mark.external_dependencies
def test_something():
    # Run tests from external data files

Running the whole test suite

If you want to force a complete re-run of the whole test suite, you have two options: either disable the plugin, or clear pytest’s cache:

$ py.test -p no:cov-exclude  # Disable the plugin

$ py.test --cache-clear  # Clear pytest's cache

Compatibility

As stated earlier, this plugin requires Pytest 2.8 or later since it depends on the new cache module.

While PyPy is supported, the ujson library used for faster serialization/deserialization is not available, so a fallback to the default JSON implementation is used instead. Because of this, the tests might actually run slower with this plugin under PyPy.

Project details


Download files

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

Source Distributions

pytest-cov-exclude-0.0.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distributions

pytest_cov_exclude-0.0.4-py3.5.egg (16.9 kB view details)

Uploaded Source

pytest_cov_exclude-0.0.4-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-cov-exclude-0.0.4.tar.gz.

File metadata

File hashes

Hashes for pytest-cov-exclude-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2c3309675286cffb6f8d7d527363ab0ea3dc458ee1ed8d72eb23d58a531e7d3c
MD5 911e667df2dfb0286b1a9d0f20176656
BLAKE2b-256 50be7482d10e89c0ce3e8fb4ec4e6b08a41d7dd20d247798c9e315d3260f9fdc

See more details on using hashes here.

File details

Details for the file pytest-cov-exclude-0.0.4.macosx-10.11-x86_64.tar.gz.

File metadata

File hashes

Hashes for pytest-cov-exclude-0.0.4.macosx-10.11-x86_64.tar.gz
Algorithm Hash digest
SHA256 073367e512eddf431801b288c9e09c6f7654d1d7e17c177355d6da3322b97b38
MD5 73fec5234f76d67e265bac066b87078e
BLAKE2b-256 806ce75ad163dc3c3390dfb420bb5228c09f3793b4d29b2f5be4616c58dff075

See more details on using hashes here.

File details

Details for the file pytest_cov_exclude-0.0.4-py3.5.egg.

File metadata

File hashes

Hashes for pytest_cov_exclude-0.0.4-py3.5.egg
Algorithm Hash digest
SHA256 938d045e0ad488a355e31c0ee4184d5c8fc13cadd16b3570ffde34b89e032399
MD5 b93c23e7832a28dd2cb6b82277b80f50
BLAKE2b-256 2f09506a39fcd25a6f3582bdff39ee9afe2a540de63ea43a48281d662f57366b

See more details on using hashes here.

File details

Details for the file pytest_cov_exclude-0.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_cov_exclude-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f056592997a1a7bb35bb144f9a1402127236defaaee51167f5a92b8ee900af1c
MD5 2a2f58a3a8c8ebb586416f730d9fadd4
BLAKE2b-256 18257069476c1991582b6b356b67a4e721f1ecf2b96a4110000dac88557cc622

See more details on using hashes here.

Supported by

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