summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-01-09 20:57:37 -0500
committerNed Batchelder <ned@nedbatchelder.com>2010-01-09 20:57:37 -0500
commit46b0b4bc9fcbe56cb5d8782703f327366455bd93 (patch)
tree0a60f1ff1b2b42ce7cf1becd74c6f37ef37161ea /coverage
parent488205aed767918e92d378d9483f7b471bf7aefd (diff)
downloadpython-coveragepy-46b0b4bc9fcbe56cb5d8782703f327366455bd93.tar.gz
XML output file is configurable in .rc file.
Diffstat (limited to 'coverage')
-rw-r--r--coverage/cmdline.py2
-rw-r--r--coverage/config.py7
-rw-r--r--coverage/control.py13
3 files changed, 17 insertions, 5 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index e82cf27..60f9cdd 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 9307fad..8f508f2 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 3a1b7f0..5c25380 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(