[py-svn] pytest-coverage commit 49dc7ecad578: Added ability to output coverage in xml format.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Mar 27 06:57:13 CET 2010


# HG changeset patch -- Bitbucket.org
# Project pytest-coverage
# URL http://bitbucket.org/prologic/pytest-coverage/overview/
# User Meme Dough <memedough at gmail.com>
# Date 1269668143 -39600
# Node ID 49dc7ecad578e96e53fbf1e96161fc24897400db
# Parent  6f0bac2b3873fff9a48f318d5fc49c468b26aa76
Added ability to output coverage in xml format.

--- a/pytest_coverage.py
+++ b/pytest_coverage.py
@@ -17,15 +17,19 @@ def pytest_addoption(parser):
             help='(multi allowed) only include info from specified package.')
     group.addoption('--cover-report', action='store', default=None,
             dest='report_type', type="choice", 
-            choices=['report', 'annotate', 'html'],
+            choices=['report', 'annotate', 'html', 'xml'],
             help="""
                 html: Directory for html output.
                 report: Output a text report.
                 annotate: Annotate your source code for which lines were executed and which were not.
+                xml: Output an xml report compatible with the cobertura plugin for hudson.
             """.strip())
     group.addoption('--cover-directory', action='store', default=None,
             dest='directory', 
             help='Directory for the reports (html / annotate results) defaults to ./coverage')
+    group.addoption('--cover-xml-file', action='store', default=None,
+            dest='xml_file',
+            help='File for the xml report defaults to ./coverage.xml')
     group.addoption('--cover-show-missing', action='store_true', default=False,
             dest='show_missing',
             help='Show missing files')
@@ -68,6 +72,7 @@ class DoCoverage:
         #omit = config.getvalue('omit')
         report_type = config.getvalue('report_type') or 'report'
         directory = config.getvalue('directory') or 'coverage'
+        xml_file = config.getvalue('xml_file') or 'coverage.xml'
 
         
         # Set up the report_args
@@ -98,3 +103,5 @@ class DoCoverage:
             self._coverage.annotate(directory=directory, **report_type)
         elif report_type == 'html':
             self._coverage.html_report(directory=directory, **report_args)
+        elif report_type == 'xml':
+            self._coverage.xml_report(outfile=xml_file, **report_args)



More information about the pytest-commit mailing list