~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-29 22:03:03 UTC
  • mfrom: (5416.2.6 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
(mbp) Add 'break-lock --force'

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
41
41
 
42
42
    def test_command_help_includes_see_also(self):
43
43
        class cmd_WithSeeAlso(commands.Command):
44
 
            """A sample command."""
 
44
            __doc__ = """A sample command."""
45
45
            _see_also = ['foo', 'bar']
46
46
        cmd = cmd_WithSeeAlso()
47
47
        helptext = cmd.get_help_text()
56
56
    def test_get_help_text(self):
57
57
        """Commands have a get_help_text method which returns their help."""
58
58
        class cmd_Demo(commands.Command):
59
 
            """A sample command."""
 
59
            __doc__ = """A sample command."""
60
60
        cmd = cmd_Demo()
61
61
        helptext = cmd.get_help_text()
62
62
        self.assertStartsWith(helptext,
67
67
 
68
68
    def test_command_with_additional_see_also(self):
69
69
        class cmd_WithSeeAlso(commands.Command):
70
 
            """A sample command."""
 
70
            __doc__ = """A sample command."""
71
71
            _see_also = ['foo', 'bar']
72
72
        cmd = cmd_WithSeeAlso()
73
73
        helptext = cmd.get_help_text(['gam'])
81
81
 
82
82
    def test_command_only_additional_see_also(self):
83
83
        class cmd_WithSeeAlso(commands.Command):
84
 
            """A sample command."""
 
84
            __doc__ = """A sample command."""
85
85
        cmd = cmd_WithSeeAlso()
86
86
        helptext = cmd.get_help_text(['gam'])
87
87
        self.assertEndsWith(
95
95
    def test_get_help_topic(self):
96
96
        """The help topic for a Command is its name()."""
97
97
        class cmd_foo_bar(commands.Command):
98
 
            """A sample command."""
 
98
            __doc__ = """A sample command."""
99
99
        cmd = cmd_foo_bar()
100
100
        self.assertEqual(cmd.name(), cmd.get_help_topic())
101
101
 
102
102
    def test_formatted_help_text(self):
103
103
        """Help text should be plain text by default."""
104
104
        class cmd_Demo(commands.Command):
105
 
            """A sample command.
 
105
            __doc__ = """A sample command.
106
106
 
107
107
            :Examples:
108
108
                Example 1::
112
112
                Example 2::
113
113
 
114
114
                    cmd arg2
 
115
 
 
116
                A code block follows.
 
117
 
 
118
                ::
 
119
 
 
120
                    bzr Demo something
115
121
            """
116
122
        cmd = cmd_Demo()
117
123
        helptext = cmd.get_help_text()
134
140
            '    Example 2:\n'
135
141
            '\n'
136
142
            '        cmd arg2\n'
 
143
            '\n'
 
144
            '    A code block follows.\n'
 
145
            '\n'
 
146
            '        bzr Demo something\n'
137
147
            '\n')
138
148
        helptext = cmd.get_help_text(plain=False)
139
149
        self.assertEquals(helptext,
154
164
            '    Example 2::\n'
155
165
            '\n'
156
166
            '        cmd arg2\n'
 
167
            '\n'
 
168
            '    A code block follows.\n'
 
169
            '\n'
 
170
            '    ::\n'
 
171
            '\n'
 
172
            '        bzr Demo something\n'
157
173
            '\n')
158
174
 
159
175
    def test_concise_help_text(self):
160
176
        """Concise help text excludes the descriptive sections."""
161
177
        class cmd_Demo(commands.Command):
162
 
            """A sample command.
 
178
            __doc__ = """A sample command.
163
179
 
164
180
            Blah blah blah.
165
181
 
206
222
    def test_help_custom_section_ordering(self):
207
223
        """Custom descriptive sections should remain in the order given."""
208
224
        class cmd_Demo(commands.Command):
209
 
            """A sample command.
 
225
            __doc__ = """A sample command.
210
226
 
211
227
            Blah blah blah.
212
228
 
252
268
    def test_help_text_custom_usage(self):
253
269
        """Help text may contain a custom usage section."""
254
270
        class cmd_Demo(commands.Command):
255
 
            """A sample command.
 
271
            __doc__ = """A sample command.
256
272
 
257
273
            :Usage:
258
274
                cmd Demo [opts] args