summaryrefslogtreecommitdiff
path: root/tests/test_cmdline.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-11-26 15:14:56 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-11-26 15:14:56 -0500
commit1d22bc523999eaedf72d76d1a4d9cf12add095de (patch)
tree11bd7441cbf76220b579ef374a45708b0e1dc0e7 /tests/test_cmdline.py
parent3db03dcfba8bba6e31b3c37d86de4ab0b348874a (diff)
downloadpython-coveragepy-git-1d22bc523999eaedf72d76d1a4d9cf12add095de.tar.gz
Use a function instead of a method to show help
Diffstat (limited to 'tests/test_cmdline.py')
-rw-r--r--tests/test_cmdline.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index fd2821b0..51112602 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -71,7 +71,7 @@ class BaseCmdLineTest(CoverageTest):
return mk
# Global names in cmdline.py that will be mocked during the tests.
- MOCK_GLOBALS = ['Coverage', 'PyRunner']
+ MOCK_GLOBALS = ['Coverage', 'PyRunner', 'show_help']
def mock_command_line(self, args, options=None):
"""Run `args` through the command line, with a Mock.
@@ -94,7 +94,7 @@ class BaseCmdLineTest(CoverageTest):
for patcher in patchers:
patcher.start()
try:
- ret = command_line(args, _help_fn=mk.help_fn)
+ ret = command_line(args)
finally:
for patcher in patchers:
patcher.stop()
@@ -110,7 +110,6 @@ class BaseCmdLineTest(CoverageTest):
code = textwrap.dedent(code)
expected = self.model_object()
globs = {n: getattr(expected, n) for n in self.MOCK_GLOBALS}
- globs['self'] = expected
code_obj = compile(code, "<code>", "exec")
eval(code_obj, globs, {}) # pylint: disable=eval-used
@@ -151,9 +150,9 @@ class BaseCmdLineTest(CoverageTest):
mk, status = self.mock_command_line(args)
self.assertEqual(status, ret, "Wrong status: got %s, wanted %s" % (status, ret))
if help_msg:
- self.assertEqual(mk.mock_calls[-1], ('help_fn', (help_msg,), {}))
+ self.assertEqual(mk.mock_calls[-1], ('show_help', (help_msg,), {}))
else:
- self.assertEqual(mk.mock_calls[-1], ('help_fn', (), {'topic': topic}))
+ self.assertEqual(mk.mock_calls[-1], ('show_help', (), {'topic': topic}))
class BaseCmdLineTestTest(BaseCmdLineTest):
@@ -273,10 +272,10 @@ class CmdLineTest(BaseCmdLineTest):
self.cmd_help("--help", topic="help", ret=OK)
def test_help_command(self):
- self.cmd_executes("help", "self.help_fn(topic='help')")
+ self.cmd_executes("help", "show_help(topic='help')")
def test_cmd_help(self):
- self.cmd_executes("run --help", "self.help_fn(parser='<CmdOptionParser:run>')")
+ self.cmd_executes("run --help", "show_help(parser='<CmdOptionParser:run>')")
self.cmd_executes_same("help run", "run --help")
def test_html(self):
@@ -593,7 +592,7 @@ class CmdLineTest(BaseCmdLineTest):
def test_run_from_config_but_empty(self):
self.cmd_executes("run", """\
cov = Coverage()
- self.help_fn('Nothing to do.')
+ show_help('Nothing to do.')
""",
ret=ERR,
options={"run:command_line": ""},
@@ -602,13 +601,13 @@ class CmdLineTest(BaseCmdLineTest):
def test_run_dashm_only(self):
self.cmd_executes("run -m", """\
cov = Coverage()
- self.help_fn('No module specified for -m')
+ show_help('No module specified for -m')
""",
ret=ERR,
)
self.cmd_executes("run -m", """\
cov = Coverage()
- self.help_fn('No module specified for -m')
+ show_help('No module specified for -m')
""",
ret=ERR,
options={"run:command_line": "myprog.py"}