diff options
author | Ned Batchelder <nedbat@gmail.com> | 2014-03-01 06:30:37 -0500 |
---|---|---|
committer | Ned Batchelder <nedbat@gmail.com> | 2014-03-01 06:30:37 -0500 |
commit | 507471475e468322d76e668e8f1a7eb443aab594 (patch) | |
tree | f05e4f0d01425d8bf791f1ce7a437742ce85ba9b /coverage/control.py | |
parent | ce11ef95ffa9a4d5b2422dfe1a65fabda695bcb2 (diff) | |
parent | 4e1a87c430f9776fa0d4f0a1655f052a097859cd (diff) | |
download | python-coveragepy-git-507471475e468322d76e668e8f1a7eb443aab594.tar.gz |
Merged in offbyone/coverage.py (pull request #31)
Resolve #285 - precreate the XML report's output directory if it does
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 7 |
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: |