~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-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007 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
 
            __doc__ = """A sample command."""
 
44
            """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
 
            __doc__ = """A sample command."""
 
59
            """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
 
            __doc__ = """A sample command."""
 
70
            """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
 
            __doc__ = """A sample command."""
 
84
            """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
 
            __doc__ = """A sample command."""
 
98
            """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
 
            __doc__ = """A sample command.
 
105
            """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
121
115
            """
122
116
        cmd = cmd_Demo()
123
117
        helptext = cmd.get_help_text()
140
134
            '    Example 2:\n'
141
135
            '\n'
142
136
            '        cmd arg2\n'
143
 
            '\n'
144
 
            '    A code block follows.\n'
145
 
            '\n'
146
 
            '        bzr Demo something\n'
147
137
            '\n')
148
138
        helptext = cmd.get_help_text(plain=False)
149
139
        self.assertEquals(helptext,
164
154
            '    Example 2::\n'
165
155
            '\n'
166
156
            '        cmd arg2\n'
167
 
            '\n'
168
 
            '    A code block follows.\n'
169
 
            '\n'
170
 
            '    ::\n'
171
 
            '\n'
172
 
            '        bzr Demo something\n'
173
157
            '\n')
174
158
 
175
159
    def test_concise_help_text(self):
176
160
        """Concise help text excludes the descriptive sections."""
177
161
        class cmd_Demo(commands.Command):
178
 
            __doc__ = """A sample command.
 
162
            """A sample command.
179
163
 
180
164
            Blah blah blah.
181
165
 
222
206
    def test_help_custom_section_ordering(self):
223
207
        """Custom descriptive sections should remain in the order given."""
224
208
        class cmd_Demo(commands.Command):
225
 
            __doc__ = """A sample command.
 
209
            """A sample command.
226
210
 
227
211
            Blah blah blah.
228
212
 
268
252
    def test_help_text_custom_usage(self):
269
253
        """Help text may contain a custom usage section."""
270
254
        class cmd_Demo(commands.Command):
271
 
            __doc__ = """A sample command.
 
255
            """A sample command.
272
256
 
273
257
            :Usage:
274
258
                cmd Demo [opts] args