I can generate a type "coverage" report with mypy via
mypy . --html-report mypy-report
and a pytest coverage report with pytest-cov
pytest --cov=app --cov-report=html
Is there a way to combine both reports? I would be interested in code that is neither covered by unit tests nor by mypy.
I spent a little time on this, and made some progress, but don't have a fully working solution.
Both pytest
and mypy
have flags to emit an XML-based report, and the one common schema they share is for the Java-based Cobertura tool.
Example invocation to produce an XML file for each:
pytest --cov=app --cov-report=xml:pytest-cobertura.xml
mypy app.py --cobertura-xml-report .
After this, you'll have two similar XML files named:
pytest-cobertura.xml
coverage.xml
- mypy
will only allow a directory, not a filenameI've explored trying to merge these two files into a single one, but haven't been able to successfully do so in the time I've spent on this - but it should be something along the lines of parsing the XML tree and merging the two sets of lines
XML tags and creating a combined.xml
file.
Right now, each file individually can be rendered to either terminal or HTML with the pycobertura
tool, like so:
pycobertura show --format html --output coverage.html combined.xml
I haven't been able to figure out the merging just yet, but wanted to give you what I had figured out.
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