36
class TestHelp(tests.TestCase):
39
tests.TestCase.setUp(self)
40
commands.install_bzr_command_hooks()
43
36
class TestCommandHelp(tests.TestCase):
44
37
"""Tests for help on commands."""
39
def assertCmdHelp(self, expected, cmd):
40
self.assertEqualDiff(textwrap.dedent(expected), cmd.get_help_text())
46
42
def test_command_help_includes_see_also(self):
47
43
class cmd_WithSeeAlso(commands.Command):
48
44
__doc__ = """A sample command."""
49
45
_see_also = ['foo', 'bar']
50
cmd = cmd_WithSeeAlso()
51
helptext = cmd.get_help_text()
54
' -v, --verbose Display more information.\n'
55
' -q, --quiet Only display errors and warnings.\n'
56
' -h, --help Show help message.\n'
58
'See also: bar, foo\n')
46
self.assertCmdHelp('''\
47
Purpose: A sample command.
48
Usage: bzr WithSeeAlso
51
--usage Show usage message and options.
52
-v, --verbose Display more information.
53
-q, --quiet Only display errors and warnings.
54
-h, --help Show help message.
60
60
def test_get_help_text(self):
61
61
"""Commands have a get_help_text method which returns their help."""
62
62
class cmd_Demo(commands.Command):
63
63
__doc__ = """A sample command."""
64
self.assertCmdHelp('''\
65
Purpose: A sample command.
69
--usage Show usage message and options.
70
-v, --verbose Display more information.
71
-q, --quiet Only display errors and warnings.
72
-h, --help Show help message.
65
77
helptext = cmd.get_help_text()
66
78
self.assertStartsWith(helptext,
485
class TestHelp(tests.TestCase):
488
tests.TestCase.setUp(self)
489
commands.install_bzr_command_hooks()
473
492
class TestRegisteredTopic(TestHelp):
474
493
"""Tests for the RegisteredTopic class."""
481
500
self.assertEqual('basic', topic.topic)
483
502
def test_get_help_text(self):
484
"""A RegisteredTopic returns the get_detail results for get_help_text."""
503
"""RegisteredTopic returns the get_detail results for get_help_text."""
485
504
topic = help_topics.RegisteredTopic('commands')
486
505
self.assertEqual(help_topics.topic_registry.get_detail('commands'),
487
topic.get_help_text())
506
topic.get_help_text())
489
508
def test_get_help_text_with_additional_see_also(self):
490
509
topic = help_topics.RegisteredTopic('commands')
504
523
def test_get_help_topic(self):
505
"""The help topic for a RegisteredTopic is its topic from construction."""
524
"""The help topic for RegisteredTopic is its topic from construction."""
506
525
topic = help_topics.RegisteredTopic('foobar')
507
526
self.assertEqual('foobar', topic.get_help_topic())
508
527
topic = help_topics.RegisteredTopic('baz')