diff options
author | Chris Rose <chrisros@amazon.com> | 2014-02-03 11:49:19 -0800 |
---|---|---|
committer | Chris Rose <chrisros@amazon.com> | 2014-02-03 11:49:19 -0800 |
commit | 7a8a17e2b24a7feac0b3a660cafb5d01e1838872 (patch) | |
tree | 6cc128e135437172fe5c83b7bad2a62954c1477a /coverage/control.py | |
parent | 442a0ba30c5c803e649331d8c6e1e449fcc1a161 (diff) | |
download | python-coveragepy-git-7a8a17e2b24a7feac0b3a660cafb5d01e1838872.tar.gz |
Resolve #285 - precreate the XML report's output directory if it does
not exist yet.
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/coverage/control.py b/coverage/control.py index d5e2c6f8..5c126b65 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: |