[TIP] how to save coverage report output to a file

Ned Batchelder ned at nedbatchelder.com
Thu Jan 17 14:40:05 PST 2019


The text report is written to stdout, so the usual redirection will work:

     coverage report > coverage.report.outfile

--Ned.

On 1/17/19 9:22 AM, DZIOBEK, JOE wrote:
>
> Hello,
>
> I am executing the “coverage pytest” command sequence below.
>
> We want to save the output of the coverage report command, so that we 
> can then use it later in a SonarScanner command.
>
> How do I save the coverage report output?
>
> In the example below, the –o option works for “coverage xml”
>
> But if I use the same –o option for “coverage report” command, I get 
> the error shown below.
>
> Thanks for your help - Joe
>
>     coverage run -m --source=subfolder pytest subfolder/test_scriptA.py
>
>     coverage xml -o ./coverage.xml.outfile
>
>     cat ./coverage.xml.outfile # file with contents was created
>
>     coverage report -o ./coverage.report.outfile
>
> ERROR: InvocationError for command 
> 'C:\\Users\\jd5948\\.tox\\py27\\Scripts\\coverage.EXE report -o 
> ./coverage.outfile' (exited with code 1)
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20190117/82152915/attachment.htm>


More information about the testing-in-python mailing list