14

Using coverage with pytests is a very useful tool.

Html reporting allows for nice output, however through command line, can't find an option to modify the default output directory (htmlcov)

example command line:

python -m pytest lib_being_tested\tests --cov lib_being_tested.module --cov-report=html

2 Answers 2

31

now (3 years later) you can change the default output directory directly in command line:

python -m pytest --cov --cov-report=html:reports/html_dir --cov-report=xml:reports/coverage.xml lib_being_tested.module

Missing directories are created on the fly

Simeon's answer is still relevant to choose this output directory through coverage configuration file

12

This configuration option isn't part of pytest-cov.

In the configuration file for the underlying tool coverage.py, which is called .coveragerc by default, you can add:

[html]
directory = differentname

See the documentation for details: https://github.com/nedbat/coveragepy/blob/master/doc/config.rst

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.