summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-03-08 21:06:01 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-03-08 21:06:01 -0500
commit8d7ff030459280d2f20b9c4facf7a21ede37a3b0 (patch)
tree4cf555ac2d3234a1aa03552e237dc374e797b6f5
parente63f0b3477b0c097e871ef2a3169191cf1cd5d2d (diff)
downloadpython-coveragepy-8d7ff030459280d2f20b9c4facf7a21ede37a3b0.tar.gz
Refactor command_line into a function.
-rw-r--r--tests/coveragetest.py16
-rw-r--r--tests/test_cmdline.py8
2 files changed, 18 insertions, 6 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index cacd436..f349196 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 223e131..abcc79f 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