pytest plugin

overview

produces coverage reports. integrates coverage.py with pytest

installation

  • pip install pytest-cov
  • distributed testing: pip install pytest-xdist

configuration

  • .coveragerc file in root project dir (specifically configured to ignore django artifacts):
    .coveragerc
    [run]
    omit =
      *apps.py,
      *settings.py,
      *urls.py,
      *wsgi.py,
      *asgi.py,
      manage.py,
      config.py,
      config-3.py,
      */migrations/*,
      */tests/*,
    branch = True

usage

  • pytest --cov=.
  • to create a coverage html document: pytest --cov=. --cov-report=html