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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With