diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-30 10:10:08 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-30 10:10:08 -0400 |
commit | f176032f56c91a1f8a2d1b763f96955e47c0a121 (patch) | |
tree | f064159f89669f18988b814bde7b44c3d48c3c61 | |
parent | 8bdff4ef8448078d06e4d7aba2d2892b8b9b7ac7 (diff) | |
download | python-coveragepy-git-f176032f56c91a1f8a2d1b763f96955e47c0a121.tar.gz |
Get --append working again.
-rw-r--r-- | coverage/cmdline.py | 5 | ||||
-rw-r--r-- | coverage/control.py | 12 | ||||
-rw-r--r-- | tests/test_cmdline.py | 2 |
3 files changed, 9 insertions, 10 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index a6ae7c3f..ee239b2d 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -577,10 +577,7 @@ class CoverageScript(object): self.coverage.stop() if code_ran: if options.append: - from coverage.data import CoverageData - old_data = CoverageData() - old_data.read_file(self.coverage.config.data_file) - self.coverage.data.update(old_data) + self.coverage.combine(data_paths=[self.coverage.config.data_file]) self.coverage.save() # Restore the old path diff --git a/coverage/control.py b/coverage/control.py index deeeae45..8e51c2c0 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -708,19 +708,21 @@ class Coverage(object): self.get_data() self.data_files.write(self.data, suffix=self.data_suffix) - def combine(self, data_dirs=None): + def combine(self, data_paths=None): """Combine together a number of similarly-named coverage data files. All coverage data files whose name starts with `data_file` (from the coverage() constructor) will be read, and combined together into the current measurements. - `data_dirs` is a list of directories from which data files should be - combined. If no list is passed, then the data files from the current - directory will be combined. + `data_paths` is a list of files or directories from which data should + be combined. If no list is passed, then the data files from the + directory indicated by the current data file (probably the current + directory) will be combined. """ self._init() + self.get_data() aliases = None if self.config.paths: @@ -730,7 +732,7 @@ class Coverage(object): for pattern in paths[1:]: aliases.add(pattern, result) - self.data_files.combine_parallel_data(self.data, aliases=aliases, data_paths=data_dirs) + self.data_files.combine_parallel_data(self.data, aliases=aliases, data_paths=data_paths) def get_data(self): """Get the collected data and reset the collector. diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index cbc44efb..20444715 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -350,10 +350,10 @@ class CmdLineTest(BaseCmdLineTest): # run -a calls coverage.load first without erasing. self.cmd_executes("run -a foo.py", """\ .coverage() - .load() .start() .run_python_file('foo.py', ['foo.py']) .stop() + .combine(data_paths=['.coverage']) .save() """) # --timid sets a flag, and program arguments get passed through. |