summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/coverage/control.py b/coverage/control.py
index d5e2c6f8..38c6cb4f 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -692,6 +692,13 @@ class coverage(object):
if self.config.xml_output == '-':
outfile = sys.stdout
else:
+ # Ensure that the output directory is created; done here
+ # because this report pre-opens the output file.
+ # HTMLReport does this using the Report plumbing because
+ # its task is more complex, being multiple files.
+ output_dir = os.path.dirname(self.config.xml_output)
+ if output_dir and not os.path.isdir(output_dir):
+ os.makedirs(output_dir)
outfile = open(self.config.xml_output, "w")
file_to_close = outfile
try: