Commits

Kumar McMillan  committed 6c89c70

Adds --cover-xml/--cover-xml-file options. Issue 311

  • Participants
  • Parent commits 1efe5b5

Comments (0)

Files changed (4)

 1.1.3
 
+- Adds :option:`--cover-xml` and :option:`--cover-xml-file` (#311).
+  Patch by Timothée Peignier.
 - Adds support for :option:`--cover-branches` (related to #370).
   Patch by Timothée Peignier.
 - Fixed Unicode issue on Python 3.1 with coverage (#442)
 configuration options in your project's *setup.cfg* file, or a .noserc
 or nose.cfg file in your home directory. In any of these standard
 .ini-style config files, you put your nosetests configuration in a
-``[nosetests]`` section. Options are the same as on the command line,
+"[nosetests]" section. Options are the same as on the command line,
 with the -- prefix removed. For options that are simple switches, you
 must supply a value:
 
 
 All configuration files that are found will be loaded and their
 options combined. You can override the standard config file loading
-with the ``-c`` option.
+with the "-c" option.
 
 
 Using Plugins
 
    Produce HTML coverage information in dir
 
+--cover-branches
+
+   Include branch coverage in coverage report [NOSE_COVER_BRANCHES]
+
+--cover-xml
+
+   Produce XML coverage information
+
+--cover-xml-file=FILE
+
+   Produce XML coverage information in file
+
 --pdb
 
    Drop into debugger on errors

File nose/plugins/cover.py

                           dest="cover_branches",
                           help="Include branch coverage in coverage report "
                           "[NOSE_COVER_BRANCHES]")
+        parser.add_option("--cover-xml", action="store_true",
+                          default=env.get('NOSE_COVER_XML'),
+                          dest="cover_xml",
+                          help="Produce XML coverage information")
+        parser.add_option("--cover-xml-file", action="store",
+                          default=env.get('NOSE_COVER_XML_FILE', 'coverage.xml'),
+                          dest="cover_xml_file",
+                          metavar="FILE",
+                          help="Produce XML coverage information in file")
 
     def configure(self, options, config):
         """
             self.coverHtmlDir = options.cover_html_dir
             log.debug('Will put HTML coverage report in %s', self.coverHtmlDir)
         self.coverBranches = options.cover_branches
+        self.coverXmlFile = None
+        if options.cover_xml:
+            self.coverXmlFile = options.cover_xml_file
+            log.debug('Will put XML coverage report in %s', self.coverHtmlFile)
         if self.enabled:
             self.status['active'] = True
 
                 self.coverInstance.html_report(modules, self.coverHtmlDir)
             else:
                 self.report_html(modules)
+        if self.coverXmlFile:
+            log.debug("Generating XML coverage report")
+            self.coverInstance.xml_report(modules, self.coverXmlFile)
 
     def report_html(self, modules):
         if not os.path.exists(self.coverHtmlDir):
 
 
 .TP
+\fB\-\-cover\-branches\fR\fR
+Include branch coverage in coverage report [NOSE_COVER_BRANCHES]
+
+
+.TP
+\fB\-\-cover\-xml\fR\fR
+Produce XML coverage information
+
+
+.TP
+\fB\-\-cover\-xml\-file\fR\fR=FILE
+Produce XML coverage information in file
+
+
+.TP
 \fB\-\-pdb\fR\fR
 Drop into debugger on errors
 
 .SH COPYRIGHT
 LGPL
 
-.\" Generated by docutils manpage writer on 2011-08-05 10:25.
+.\" Generated by docutils manpage writer on 2011-10-10 09:32.
 .\"