freshcrate
Home > Frameworks > pytest-cov

pytest-cov

Pytest plugin for measuring coverage.

Description

======== Overview ======== .. start-badges .. list-table:: :stub-columns: 1 * - docs - |docs| * - tests - |github-actions| * - package - |version| |conda-forge| |wheel| |supported-versions| |supported-implementations| |commits-since| .. |docs| image:: https://readthedocs.org/projects/pytest-cov/badge/?style=flat :target: https://readthedocs.org/projects/pytest-cov/ :alt: Documentation Status .. |github-actions| image:: https://github.com/pytest-dev/pytest-cov/actions/workflows/test.yml/badge.svg :alt: GitHub Actions Status :target: https://github.com/pytest-dev/pytest-cov/actions .. |version| image:: https://img.shields.io/pypi/v/pytest-cov.svg :alt: PyPI Package latest release :target: https://pypi.org/project/pytest-cov .. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pytest-cov.svg :target: https://anaconda.org/conda-forge/pytest-cov .. |wheel| image:: https://img.shields.io/pypi/wheel/pytest-cov.svg :alt: PyPI Wheel :target: https://pypi.org/project/pytest-cov .. |supported-versions| image:: https://img.shields.io/pypi/pyversions/pytest-cov.svg :alt: Supported versions :target: https://pypi.org/project/pytest-cov .. |supported-implementations| image:: https://img.shields.io/pypi/implementation/pytest-cov.svg :alt: Supported implementations :target: https://pypi.org/project/pytest-cov .. |commits-since| image:: https://img.shields.io/github/commits-since/pytest-dev/pytest-cov/v7.1.0.svg :alt: Commits since latest release :target: https://github.com/pytest-dev/pytest-cov/compare/v7.1.0...master .. end-badges This plugin provides coverage functionality as a pytest plugin. Compared to just using ``coverage run`` this plugin does some extras: * Automatic erasing and combination of .coverage files and default reporting. * Support for detailed coverage contexts (add ``--cov-context=test`` to have the full test name including parametrization as the context). * Xdist support: you can use all of pytest-xdist's features including remote interpreters and still get coverage. * Consistent pytest behavior. If you run ``coverage run -m pytest`` you will have slightly different ``sys.path`` (CWD will be in it, unlike when running ``pytest``). All features offered by the coverage package should work, either through pytest-cov's command line options or through coverage's config file. * Free software: MIT license Installation ============ Install with pip:: pip install pytest-cov For distributed testing support install pytest-xdist:: pip install pytest-xdist Upgrading from pytest-cov 6.3 ----------------------------- `pytest-cov 6.3` and older were using a ``.pth`` file to enable coverage measurements in subprocesses. This was removed in `pytest-cov 7` - use `coverage's patch options <https://coverage.readthedocs.io/en/latest/config.html#run-patch>`_ to enable subprocess measurements. Uninstalling ------------ Uninstall with pip:: pip uninstall pytest-cov Under certain scenarios a stray ``.pth`` file may be left around in site-packages. * `pytest-cov 2.0` may leave a ``pytest-cov.pth`` if you installed without wheels (``easy_install``, ``setup.py install`` etc). * `pytest-cov 1.8 or older` will leave a ``init_cov_core.pth``. Usage ===== :: pytest --cov=myproj tests/ Would produce a report like:: -------------------- coverage: ... --------------------- Name Stmts Miss Cover ---------------------------------------- myproj/__init__ 2 0 100% myproj/myproj 257 13 94% myproj/feature4286 94 7 92% ---------------------------------------- TOTAL 353 20 94% Documentation ============= https://pytest-cov.readthedocs.io/en/latest/ Coverage Data File ================== The data file is erased at the beginning of testing to ensure clean data for each test run. If you need to combine the coverage of several test runs you can use the ``--cov-append`` option to append this coverage data to coverage data from previous test runs. The data file is left at the end of testing so that it is possible to use normal coverage tools to examine it. Limitations =========== For distributed testing the workers must have the pytest-cov package installed. This is needed since the plugin must be registered through setuptools for pytest to start the plugin on the worker. Security ======== To report a security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_. Tidelift will coordinate the fix and disclosure. Acknowledgements ================ Whilst this plugin has been built fresh from the ground up it has been influenced by the work done on pytest-coverage (Ross Lawley, James Mills, Holger Krekel) and nose-cover (Jason Pellerin) which are other coverage plugins. Ned Batchelder for coverage and its ability to combine the covera

Release History

VersionChangesUrgencyDate
7.1.0Imported from PyPI (7.1.0)Low4/21/2026
v7.1.0Tag v7.1.0Low3/21/2026
v7.0.0Tag v7.0.0Low9/9/2025
v6.3.0Tag v6.3.0Low9/6/2025
v6.2.1Tag v6.2.1Low6/12/2025
v6.2.0Tag v6.2.0Low6/11/2025
v6.1.1Tag v6.1.1Low4/5/2025
v6.1.0Tag v6.1.0Low4/1/2025
v6.0.0Tag v6.0.0Low10/29/2024
v5.0.0Tag v5.0.0Low3/24/2024
v4.1.0Tag v4.1.0Low5/24/2023
v4.0.0Tag v4.0.0Low9/28/2022
v3.0.0Tag v3.0.0Low10/4/2021
v2.12.1Tag v2.12.1Low6/1/2021
v2.12.0Tag v2.12.0Low5/14/2021
v2.11.1Tag v2.11.1Low1/20/2021
v2.11.0Tag v2.11.0Low1/18/2021
v2.10.1Tag v2.10.1Low8/14/2020
v2.10.0Tag v2.10.0Low6/12/2020
v2.9.0Tag v2.9.0Low5/22/2020
v2.8.1Tag v2.8.1Low10/5/2019

Dependencies & License Audit

Loading dependencies...

Similar Packages

schemathesisProperty-based testing framework for Open API and GraphQL based apps4.15.2
pytest-subtestsunittest subTest() support and subtests fixture0.15.0
seleniumbaseA complete web automation framework for end-to-end testing.4.48.2
pytest-recordingA pytest plugin powered by VCR.py to record and replay HTTP traffic0.13.4
pytest-randomlyPytest plugin to randomly order tests and control random.seed.4.1.0