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 filename
I'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.
mypy
(--lineprecision-report
) andpytest
would make parsing the common coverage much easier. – Oxime