All Projects → pytest-dev → Pytest Cov

pytest-dev / Pytest Cov

Licence: mit
Coverage plugin for pytest.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Pytest Cov

Unittest Xml Reporting
unittest-based test runner with Ant/JUnit like XML reporting.
Stars: ✭ 255 (-74.06%)
Mutual labels:  pytest
Coveralls Python
Show coverage stats online via coveralls.io
Stars: ✭ 455 (-53.71%)
Mutual labels:  pytest
Pytest Responsemock
Simplified requests calls mocking for pytest
Stars: ✭ 24 (-97.56%)
Mutual labels:  pytest
Pytest Picked
Run the tests related to the changed files (according to Git) 🤓
Stars: ✭ 262 (-73.35%)
Mutual labels:  pytest
Allure Python
Allure integrations for Python test frameworks
Stars: ✭ 387 (-60.63%)
Mutual labels:  pytest
Pytest Benchmark
py.test fixture for benchmarking code
Stars: ✭ 730 (-25.74%)
Mutual labels:  pytest
importnb
notebook files as source
Stars: ✭ 47 (-95.22%)
Mutual labels:  pytest
Pytest Django
A Django plugin for pytest.
Stars: ✭ 872 (-11.29%)
Mutual labels:  pytest
Pytest Html
Plugin for generating HTML reports for pytest results
Stars: ✭ 404 (-58.9%)
Mutual labels:  pytest
Pytest Ui
Text User Interface for running python tests
Stars: ✭ 23 (-97.66%)
Mutual labels:  pytest
Pytest Randomly
🎲 Pytest plugin to randomly order tests and control random.seed
Stars: ✭ 284 (-71.11%)
Mutual labels:  pytest
Nbval
A py.test plugin to validate Jupyter notebooks
Stars: ✭ 347 (-64.7%)
Mutual labels:  pytest
Tavern
A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax
Stars: ✭ 760 (-22.69%)
Mutual labels:  pytest
Websauna
Websauna is a full stack Python web framework for building web services and back offices with admin interface and sign up process
Stars: ✭ 259 (-73.65%)
Mutual labels:  pytest
Pytest Requests
HTTP(S) testing with pytest and requests.
Stars: ✭ 24 (-97.56%)
Mutual labels:  pytest
pytest-reportlog
Replacement for the --resultlog option, focused in simplicity and extensibility
Stars: ✭ 36 (-96.34%)
Mutual labels:  pytest
Pytest Sugar
a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)
Stars: ✭ 689 (-29.91%)
Mutual labels:  pytest
Jest Pytest
A Jest and Pytest integration made in heaven 💖
Stars: ✭ 28 (-97.15%)
Mutual labels:  pytest
Pytest Patterns
A couple of examples showing how pytest and its plugins can be combined to solve real-world needs.
Stars: ✭ 24 (-97.56%)
Mutual labels:  pytest
Schemathesis
A modern API testing tool for web applications built with Open API and GraphQL specifications.
Stars: ✭ 768 (-21.87%)
Mutual labels:  pytest

======== Overview

.. start-badges

.. list-table:: :stub-columns: 1

* - docs
  - |docs|
* - tests
  - | |travis| |appveyor| |requires|
* - 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

.. |travis| image:: https://api.travis-ci.com/pytest-dev/pytest-cov.svg?branch=master :alt: Travis-CI Build Status :target: https://travis-ci.com/github/pytest-dev/pytest-cov

.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/pytest-dev/pytest-cov?branch=master&svg=true :alt: AppVeyor Build Status :target: https://ci.appveyor.com/project/pytestbot/pytest-cov

.. |requires| image:: https://requires.io/github/pytest-dev/pytest-cov/requirements.svg?branch=master :alt: Requirements Status :target: https://requires.io/github/pytest-dev/pytest-cov/requirements/?branch=master

.. |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

.. |commits-since| image:: https://img.shields.io/github/commits-since/pytest-dev/pytest-cov/v2.11.1.svg :alt: Commits since latest release :target: https://github.com/pytest-dev/pytest-cov/compare/v2.10.1...master

.. |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

.. end-badges

This plugin produces coverage reports. Compared to just using coverage run this plugin does some extras:

  • Subprocess support: you can fork or run stuff in a subprocess and will get covered without any fuss.
  • Xdist support: you can use all of pytest-xdist's features 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 ancient pytest-cov

pytest-cov 2.0 is using a new .pth file (pytest-cov.pth). You may want to manually remove the older init_cov_core.pth from site-packages as it's not automatically removed.

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

http://pytest-cov.rtfd.org/

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.

For subprocess measurement environment variables must make it from the main process to the subprocess. The python used by the subprocess must have pytest-cov installed. The subprocess must do normal site initialisation so that the environment variables can be detected and coverage started.

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 coverage results of parallel runs.

Holger Krekel for pytest with its distributed testing support.

Jason Pellerin for nose.

Michael Foord for unittest2.

No doubt others have contributed to these tools as well.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].