diff options
-rw-r--r-- | tests/coveragetest.py | 16 | ||||
-rw-r--r-- | tests/test_cmdline.py | 8 |
2 files changed, 18 insertions, 6 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index cacd4362..f3491965 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -353,8 +353,7 @@ class CoverageTest( Returns None. """ - script = CoverageScript(_covpkg=_covpkg) - ret_actual = script.command_line(shlex.split(args)) + ret_actual = command_line(args, _covpkg=_covpkg) self.assertEqual(ret_actual, ret) coverage_command = "coverage" @@ -485,3 +484,16 @@ class DebugControlString(DebugControl): def get_output(self): """Get the output text from the `DebugControl`.""" return self.output.getvalue() + + +def command_line(args, **kwargs): + """Run `args` through the CoverageScript command line. + + `kwargs` are the keyword arguments to the CoverageScript constructor. + + Returns the return code from CoverageScript.command_line. + + """ + script = CoverageScript(**kwargs) + ret = script.command_line(shlex.split(args)) + return ret diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 223e1313..abcc79f5 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -5,7 +5,6 @@ import pprint import re -import shlex import sys import textwrap @@ -18,7 +17,7 @@ from coverage.config import CoverageConfig from coverage.data import CoverageData, CoverageDataFiles from coverage.misc import ExceptionDuringRun -from tests.coveragetest import CoverageTest, OK, ERR +from tests.coveragetest import CoverageTest, OK, ERR, command_line class BaseCmdLineTest(CoverageTest): @@ -73,11 +72,12 @@ class BaseCmdLineTest(CoverageTest): m = self.model_object() m.path_exists.return_value = path_exists - ret = coverage.cmdline.CoverageScript( + 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, - ).command_line(shlex.split(args)) + ) return m, ret |