Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a different html output directory for coverage report with pytest?

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
like image 675
Efren Avatar asked Dec 18 '14 00:12

Efren


People also ask

How do I generate a Pytest HTML report?

To generate the report, we have to move from the current directory to the directory of the Pytest file that we want to execute. Then run the command: pytest --html=report. html. After this command is successfully executed, a new file called the report.


1 Answers

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

like image 162
Géraud Avatar answered Sep 18 '22 09:09

Géraud