Python pytest-cov

From wikinotes

Documentation

configuration docs https://coverage.readthedocs.io/en/latest/config.html

Install

pip install pytest-cov

Usage

cli

cd myproject/
pytest --cov=myproject/   # run tests, and print coverage summary *for files under myproject/*

NOTE:

If you need to test multiple directories, simply write multiple .coverage files, them combine them using coverage combine .coverage1 .coverage2 ...

setup.py

setup.cfg

[aliases]
test=pytest

[tool:pytest]
testpaths = plugin/tests
addopts = --cov=plugin/taskmage2

setup.py

#!/usr/bin/env python
import setuptools

setuptools.setup(
    name='project',
    version='1.0.0',
    author='Will Pittman',
    setup_requires=[
        'pytest-runner',
    ],
    tests_require=[
        'pytest',
        'pytest-cov',
    ],
)