diff options
-rw-r--r-- | coverage/cmdline.py | 10 | ||||
-rw-r--r-- | tests/test_cmdline.py | 18 |
2 files changed, 11 insertions, 17 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 1b7955d3..14948d1c 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -392,7 +392,7 @@ class CoverageScript(object): def __init__( self, _covpkg=None, _run_python_file=None, - _run_python_module=None, _help_fn=None, _path_exists=None, + _run_python_module=None, _help_fn=None, ): # _covpkg is for dependency injection, so we can test this code. if _covpkg: @@ -405,7 +405,6 @@ class CoverageScript(object): self.run_python_file = _run_python_file or run_python_file self.run_python_module = _run_python_module or run_python_module self.help_fn = _help_fn or self.help - self.path_exists = _path_exists or os.path.exists self.global_option = False self.coverage = None @@ -619,6 +618,9 @@ class CoverageScript(object): ) return ERR + if options.append: + self.coverage.load() + # Run the script. self.coverage.start() code_ran = True @@ -634,10 +636,6 @@ class CoverageScript(object): finally: self.coverage.stop() if code_ran: - if options.append: - data_file = self.coverage.get_option("run:data_file") - if self.path_exists(data_file): - self.coverage.combine(data_paths=[data_file]) self.coverage.save() return OK diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index ecd4d8b3..b12f92ea 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -70,34 +70,31 @@ class BaseCmdLineTest(CoverageTest): return mk - def mock_command_line(self, args, path_exists=None): + def mock_command_line(self, args): """Run `args` through the command line, with a Mock. Returns the Mock it used and the status code returned. """ m = self.model_object() - m.path_exists.return_value = path_exists ret = command_line( args, _covpkg=m, _run_python_file=m.run_python_file, _run_python_module=m.run_python_module, _help_fn=m.help_fn, - _path_exists=m.path_exists, ) return m, ret - def cmd_executes(self, args, code, ret=OK, path_exists=None): + def cmd_executes(self, args, code, ret=OK): """Assert that the `args` end up executing the sequence in `code`.""" - m1, r1 = self.mock_command_line(args, path_exists=path_exists) + m1, r1 = self.mock_command_line(args) self.assertEqual(r1, ret, "Wrong status: got %r, wanted %r" % (r1, ret)) # Remove all indentation, and change ".foo()" to "m2.foo()". code = re.sub(r"(?m)^\s+", "", code) code = re.sub(r"(?m)^\.", "m2.", code) m2 = self.model_object() - m2.path_exists.return_value = path_exists code_obj = compile(code, "<code>", "exec") eval(code_obj, globals(), {'m2': m2}) # pylint: disable=eval-used @@ -366,22 +363,21 @@ class CmdLineTest(BaseCmdLineTest): # run -a combines with an existing data file before saving. self.cmd_executes("run -a foo.py", """\ .Coverage() + .load() .start() .run_python_file('foo.py', ['foo.py']) .stop() - .path_exists('.coverage') - .combine(data_paths=['.coverage']) .save() - """, path_exists=True) + """) # run -a doesn't combine anything if the data file doesn't exist. self.cmd_executes("run -a foo.py", """\ .Coverage() + .load() .start() .run_python_file('foo.py', ['foo.py']) .stop() - .path_exists('.coverage') .save() - """, path_exists=False) + """) # --timid sets a flag, and program arguments get passed through. self.cmd_executes("run --timid foo.py abc 123", """\ .Coverage(timid=True) |