diff options
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/coverage/data.py b/coverage/data.py index 11c7c01d..9359af12 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -2,7 +2,7 @@ import os -from coverage.backward import pickle, sorted # pylint: disable-msg=W0622 +from coverage.backward import pickle, sorted # pylint: disable-msg=W0622 class CoverageData(object): @@ -34,21 +34,21 @@ class CoverageData(object): `suffix` is a suffix to append to the base file name. This can be used for multiple or parallel execution, so that many coverage data files - can exist simultaneously. + can exist simultaneously. A dot will be used to join the base name and + the suffix. `collector` is a string describing the coverage measurement software. """ - self.collector = collector + self.collector = collector or 'unknown' self.use_file = True # Construct the filename that will be used for data file storage, if we # ever do any file storage. - self.filename = (basename or - os.environ.get(self.filename_env, self.filename_default)) + self.filename = basename or ".coverage" if suffix: - self.filename += suffix + self.filename += "." + suffix self.filename = os.path.abspath(self.filename) # A map from canonical Python source file name to a dictionary in @@ -169,18 +169,21 @@ class CoverageData(object): """Combine a number of data files together. Treat `self.filename` as a file prefix, and combine the data from all - of the data files starting with that prefix. + of the data files starting with that prefix plus a dot. """ data_dir, local = os.path.split(self.filename) + localdot = local + '.' for f in os.listdir(data_dir or '.'): - if f.startswith(local): + if f.startswith(localdot): full_path = os.path.join(data_dir, f) new_lines, new_arcs = self._read_file(full_path) for filename, file_data in new_lines.items(): self.lines.setdefault(filename, {}).update(file_data) for filename, file_data in new_arcs.items(): self.arcs.setdefault(filename, {}).update(file_data) + if f != local: + os.remove(full_path) def add_line_data(self, line_data): """Add executed line data. |