diff options
-rw-r--r-- | coverage/control.py | 11 | ||||
-rw-r--r-- | coverage/data.py | 14 |
2 files changed, 15 insertions, 10 deletions
diff --git a/coverage/control.py b/coverage/control.py index cb13f2ff..0cc4ee87 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -45,9 +45,14 @@ class coverage: # TODO: ignore by module as well as file? return self.file_locator.canonical_filename(filename) - def use_cache(self, usecache, cache_file=None): - self.data.usefile(usecache, cache_file) + def use_cache(self, usecache): + """Control the use of a data file (incorrectly called a cache). + `usecache` is true or false, whether to read and write data on disk. + + """ + self.data.usefile(usecache) + def get_ready(self): self.collector.reset() self.data.read(parallel=self.parallel_mode) @@ -91,7 +96,7 @@ class coverage: def group_collected_data(self): """Group the collected data by filename and reset the collector.""" - self.data.add_raw_data(self.collector.data_points()) + self.data.add_line_data(self.collector.data_points()) self.collector.reset() # Backward compatibility with version 1. diff --git a/coverage/data.py b/coverage/data.py index 06f46343..deebfbe3 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -26,10 +26,8 @@ class CoverageData: # self.executed = {} - def usefile(self, use_file=True, filename_default=None): + def usefile(self, use_file=True): self.use_file = use_file - if filename_default and not self.filename: - self.filename_default = filename_default def read(self, parallel=False): """Read coverage data from the coverage data file (if it exists).""" @@ -69,8 +67,10 @@ class CoverageData: """ try: fdata = open(filename, 'rb') - executed = pickle.load(fdata) - fdata.close() + try: + executed = pickle.load(fdata) + finally: + fdata.close() if isinstance(executed, types.DictType): return executed else: @@ -94,8 +94,8 @@ class CoverageData: for filename, file_data in new_data.items(): self.executed.setdefault(filename, {}).update(file_data) - def add_raw_data(self, data_points): - """Add raw data. + def add_line_data(self, data_points): + """Add executed line data. `data_points` is (filename, lineno) pairs. |