diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | coverage/config.py | 7 | ||||
-rw-r--r-- | coverage/control.py | 13 |
3 files changed, 17 insertions, 5 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index e82cf27c..60f9cdd3 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -506,8 +506,6 @@ class CoverageScript(object): directory=options.directory, **report_args) if 'xml' in options.actions: outfile = options.outfile - if outfile == '-': - outfile = None self.coverage.xml_report(outfile=outfile, **report_args) return OK diff --git a/coverage/config.py b/coverage/config.py index 9307fad7..8f508f28 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -29,6 +29,9 @@ class CoverageConfig(object): # Defaults for [html] self.html_dir = "htmlcov" + # Defaults for [xml] + self.xml_output = "coverage.xml" + def from_environment(self, env_var): """Read configuration from the `env_var` environment variable.""" # Timidity: for nose users, read an environment variable. This is a @@ -86,3 +89,7 @@ class CoverageConfig(object): # [html] if cp.has_option('html', 'directory'): self.html_dir = cp.get('html', 'directory') + + # [xml] + if cp.has_option('xml', 'output'): + self.xml_output = cp.get('xml', 'output') diff --git a/coverage/control.py b/coverage/control.py index 3a1b7f0f..5c253808 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -366,14 +366,21 @@ class coverage(object): """Generate an XML report of coverage results. The report is compatible with Cobertura reports. + + Each module in `morfs` is included in the report. `outfile` is the + path to write the file to, "-" will write to stdout. """ self.config.from_args( ignore_errors=ignore_errors, - omit_prefixes=omit_prefixes + omit_prefixes=omit_prefixes, + xml_output=outfile, ) - if outfile: - outfile = open(outfile, "w") + if self.config.xml_output: + if self.config.xml_output == '-': + outfile = sys.stdout + else: + outfile = open(self.config.xml_output, "w") try: reporter = XmlReporter(self, self.config.ignore_errors) reporter.report( |