From b84dd85957bff7422c7b0a54c7836c091018ec16 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Mon, 3 Feb 2014 11:49:19 -0800 Subject: Resolve #285 - precreate the XML report's output directory if it does not exist yet. --- coverage/control.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index d5e2c6f..5c126b6 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -692,6 +692,14 @@ 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: -- cgit v1.2.1