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
pytestandmypyhave 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:
After this, you'll have two similar XML files named:
pytest-cobertura.xmlcoverage.xml-mypywill 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
linesXML tags and creating acombined.xmlfile.Right now, each file individually can be rendered to either terminal or HTML with the
pycoberturatool, like so:I haven't been able to figure out the merging just yet, but wanted to give you what I had figured out.