/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2009-06-08 02:02:08 UTC
  • mto: (4446.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4447.
  • Revision ID: nmb@wartburg.edu-20090608020208-zb6y8877j6oxhml2
Fix #220067 adding more specificity to the error message when split fails

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
29
29
    )
30
30
 
31
31
 
32
 
class TestHelp(tests.TestCase):
33
 
 
34
 
    def setUp(self):
35
 
        tests.TestCase.setUp(self)
36
 
        commands.install_bzr_command_hooks()
37
 
 
38
 
 
39
32
class TestCommandHelp(tests.TestCase):
40
33
    """Tests for help on commands."""
41
34
 
42
35
    def test_command_help_includes_see_also(self):
43
36
        class cmd_WithSeeAlso(commands.Command):
44
 
            __doc__ = """A sample command."""
 
37
            """A sample command."""
45
38
            _see_also = ['foo', 'bar']
46
39
        cmd = cmd_WithSeeAlso()
47
40
        helptext = cmd.get_help_text()
56
49
    def test_get_help_text(self):
57
50
        """Commands have a get_help_text method which returns their help."""
58
51
        class cmd_Demo(commands.Command):
59
 
            __doc__ = """A sample command."""
 
52
            """A sample command."""
60
53
        cmd = cmd_Demo()
61
54
        helptext = cmd.get_help_text()
62
55
        self.assertStartsWith(helptext,
67
60
 
68
61
    def test_command_with_additional_see_also(self):
69
62
        class cmd_WithSeeAlso(commands.Command):
70
 
            __doc__ = """A sample command."""
 
63
            """A sample command."""
71
64
            _see_also = ['foo', 'bar']
72
65
        cmd = cmd_WithSeeAlso()
73
66
        helptext = cmd.get_help_text(['gam'])
81
74
 
82
75
    def test_command_only_additional_see_also(self):
83
76
        class cmd_WithSeeAlso(commands.Command):
84
 
            __doc__ = """A sample command."""
 
77
            """A sample command."""
85
78
        cmd = cmd_WithSeeAlso()
86
79
        helptext = cmd.get_help_text(['gam'])
87
80
        self.assertEndsWith(
95
88
    def test_get_help_topic(self):
96
89
        """The help topic for a Command is its name()."""
97
90
        class cmd_foo_bar(commands.Command):
98
 
            __doc__ = """A sample command."""
 
91
            """A sample command."""
99
92
        cmd = cmd_foo_bar()
100
93
        self.assertEqual(cmd.name(), cmd.get_help_topic())
101
94
 
102
95
    def test_formatted_help_text(self):
103
96
        """Help text should be plain text by default."""
104
97
        class cmd_Demo(commands.Command):
105
 
            __doc__ = """A sample command.
 
98
            """A sample command.
106
99
 
107
100
            :Examples:
108
101
                Example 1::
122
115
            '\n'
123
116
            'Options:\n'
124
117
            '  --usage        Show usage message and options.\n'
125
 
            '  -0, --null     Use an ASCII NUL (\\0) separator rather than a newline.\n'
126
118
            '  -v, --verbose  Display more information.\n'
127
119
            '  -q, --quiet    Only display errors and warnings.\n'
128
120
            '  -h, --help     Show help message.\n'
143
135
            '\n'
144
136
            ':Options:\n'
145
137
            '  --usage        Show usage message and options.\n'
146
 
            '  -0, --null     Use an ASCII NUL (\\0) separator rather than a newline.\n'
147
138
            '  -v, --verbose  Display more information.\n'
148
139
            '  -q, --quiet    Only display errors and warnings.\n'
149
140
            '  -h, --help     Show help message.\n'
161
152
    def test_concise_help_text(self):
162
153
        """Concise help text excludes the descriptive sections."""
163
154
        class cmd_Demo(commands.Command):
164
 
            __doc__ = """A sample command.
 
155
            """A sample command.
165
156
 
166
157
            Blah blah blah.
167
158
 
179
170
            '\n'
180
171
            'Options:\n'
181
172
            '  --usage        Show usage message and options.\n'
182
 
            '  -0, --null     Use an ASCII NUL (\\0) separator rather than a newline.\n'
183
173
            '  -v, --verbose  Display more information.\n'
184
174
            '  -q, --quiet    Only display errors and warnings.\n'
185
175
            '  -h, --help     Show help message.\n'
199
189
            '\n'
200
190
            'Options:\n'
201
191
            '  --usage        Show usage message and options.\n'
202
 
            '  -0, --null     Use an ASCII NUL (\\0) separator rather than a newline.\n'
203
192
            '  -v, --verbose  Display more information.\n'
204
193
            '  -q, --quiet    Only display errors and warnings.\n'
205
194
            '  -h, --help     Show help message.\n'
210
199
    def test_help_custom_section_ordering(self):
211
200
        """Custom descriptive sections should remain in the order given."""
212
201
        class cmd_Demo(commands.Command):
213
 
            __doc__ = """A sample command.
 
202
            """A sample command.
214
203
 
215
204
            Blah blah blah.
216
205
 
234
223
            '\n'
235
224
            'Options:\n'
236
225
            '  --usage        Show usage message and options.\n'
237
 
            '  -0, --null     Use an ASCII NUL (\\0) separator rather than a newline.\n'
238
226
            '  -v, --verbose  Display more information.\n'
239
227
            '  -q, --quiet    Only display errors and warnings.\n'
240
228
            '  -h, --help     Show help message.\n'
257
245
    def test_help_text_custom_usage(self):
258
246
        """Help text may contain a custom usage section."""
259
247
        class cmd_Demo(commands.Command):
260
 
            __doc__ = """A sample command.
 
248
            """A sample command.
261
249
 
262
250
            :Usage:
263
251
                cmd Demo [opts] args
278
266
            '\n'
279
267
            'Options:\n'
280
268
            '  --usage        Show usage message and options.\n'
281
 
            '  -0, --null     Use an ASCII NUL (\\0) separator rather than a newline.\n'
282
269
            '  -v, --verbose  Display more information.\n'
283
270
            '  -q, --quiet    Only display errors and warnings.\n'
284
271
            '  -h, --help     Show help message.\n'
287
274
            '  Blah blah blah.\n\n')
288
275
 
289
276
 
290
 
class TestRegisteredTopic(TestHelp):
 
277
class TestRegisteredTopic(tests.TestCase):
291
278
    """Tests for the RegisteredTopic class."""
292
279
 
293
280
    def test_contruct(self):
326
313
        self.assertEqual('baz', topic.get_help_topic())
327
314
 
328
315
 
329
 
class TestTopicIndex(TestHelp):
 
316
class TestTopicIndex(tests.TestCase):
330
317
    """Tests for the HelpTopicIndex class."""
331
318
 
332
319
    def test_default_constructable(self):
359
346
        self.assertEqual('', index.prefix)
360
347
 
361
348
 
362
 
class TestCommandIndex(TestHelp):
 
349
class TestCommandIndex(tests.TestCase):
363
350
    """Tests for the HelpCommandIndex class."""
364
351
 
365
352
    def test_default_constructable(self):