diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-08-07 11:53:27 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-08-07 11:53:27 -0400 |
commit | 1035b301586737bd44d6a8a9739e3cce53406622 (patch) | |
tree | 1427819040c2210ae8e14c694e23d2802dcded00 /coverage/data.py | |
parent | 515479de68afb93dd0829a30ff191dff707e0892 (diff) | |
download | python-coveragepy-1035b301586737bd44d6a8a9739e3cce53406622.tar.gz |
Combining twice shouldn't lose data. #412, #516
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/coverage/data.py b/coverage/data.py index 60e104d..94d8330 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -666,7 +666,7 @@ class CoverageDataFiles(object): filename += "." + suffix data.write_file(filename) - def combine_parallel_data(self, data, aliases=None, data_paths=None): + def combine_parallel_data(self, data, aliases=None, data_paths=None, strict=False): """Combine a number of data files together. Treat `self.filename` as a file prefix, and combine the data from all @@ -686,6 +686,9 @@ class CoverageDataFiles(object): cannot be read, a warning will be issued, and the file will not be deleted. + If `strict` is true, and no files are found to combine, an error is + raised. + """ # Because of the os.path.abspath in the constructor, data_dir will # never be an empty string. @@ -703,6 +706,9 @@ class CoverageDataFiles(object): else: raise CoverageException("Couldn't combine from non-existent path '%s'" % (p,)) + if strict and not files_to_combine: + raise CoverageException("No data to combine") + for f in files_to_combine: new_data = CoverageData() try: |