Skip to content

howto pytest coverage

Ludovico Bianchi edited this page Jul 13, 2022 · 1 revision

How to: run pytest and generate test coverage reports locally

Example A

Assumptions

  • You're working on a test file named test_multiperiod.py

Steps

Run the following command:

pytest --cov --cov-report html:.cov-report/ --cov-report term -k test_multiperiod

A coverage report will be generated:

  • In text format, displayed directly in the terminal
  • In HTML format (interactive): open the .cov-report/index.html file with a web browser

Further reading

Clone this wiki locally