~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2012, 2016 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Unit tests for the bzrlib.help module."""
18
18
 
19
 
import textwrap
 
19
from cStringIO import StringIO
20
20
 
21
21
from bzrlib import (
22
22
    builtins,
23
23
    commands,
24
 
    config,
25
24
    errors,
26
25
    help,
27
26
    help_topics,
28
 
    i18n,
29
27
    plugin,
30
28
    tests,
31
29
    )
32
30
 
33
 
from bzrlib.tests.test_i18n import ZzzTranslations
34
 
import re
35
 
 
36
31
 
37
32
class TestCommandHelp(tests.TestCase):
38
33
    """Tests for help on commands."""
39
34
 
40
 
    def assertCmdHelp(self, expected, cmd):
41
 
        self.assertEqualDiff(textwrap.dedent(expected), cmd.get_help_text())
42
 
 
43
35
    def test_command_help_includes_see_also(self):
44
36
        class cmd_WithSeeAlso(commands.Command):
45
 
            __doc__ = """A sample command."""
 
37
            """A sample command."""
46
38
            _see_also = ['foo', 'bar']
47
 
        self.assertCmdHelp('''\
48
 
Purpose: A sample command.
49
 
Usage:   bzr WithSeeAlso
50
 
 
51
 
Options:
52
 
  --usage        Show usage message and options.
53
 
  -q, --quiet    Only display errors and warnings.
54
 
  -v, --verbose  Display more information.
55
 
  -h, --help     Show help message.
56
 
 
57
 
See also: bar, foo
58
 
''',
59
 
                           cmd_WithSeeAlso())
 
39
        cmd = cmd_WithSeeAlso()
 
40
        helptext = cmd.get_help_text()
 
41
        self.assertEndsWith(
 
42
            helptext,
 
43
            '  -v, --verbose  Display more information.\n'
 
44
            '  -q, --quiet    Only display errors and warnings.\n'
 
45
            '  -h, --help     Show help message.\n'
 
46
            '\n'
 
47
            'See also: bar, foo\n')
60
48
 
61
49
    def test_get_help_text(self):
62
50
        """Commands have a get_help_text method which returns their help."""
63
51
        class cmd_Demo(commands.Command):
64
 
            __doc__ = """A sample command."""
65
 
        self.assertCmdHelp('''\
66
 
Purpose: A sample command.
67
 
Usage:   bzr Demo
68
 
 
69
 
Options:
70
 
  --usage        Show usage message and options.
71
 
  -q, --quiet    Only display errors and warnings.
72
 
  -v, --verbose  Display more information.
73
 
  -h, --help     Show help message.
74
 
 
75
 
''',
76
 
                           cmd_Demo())
 
52
            """A sample command."""
77
53
        cmd = cmd_Demo()
78
54
        helptext = cmd.get_help_text()
79
55
        self.assertStartsWith(helptext,
84
60
 
85
61
    def test_command_with_additional_see_also(self):
86
62
        class cmd_WithSeeAlso(commands.Command):
87
 
            __doc__ = """A sample command."""
 
63
            """A sample command."""
88
64
            _see_also = ['foo', 'bar']
89
65
        cmd = cmd_WithSeeAlso()
90
66
        helptext = cmd.get_help_text(['gam'])
91
67
        self.assertEndsWith(
92
68
            helptext,
 
69
            '  -v, --verbose  Display more information.\n'
93
70
            '  -q, --quiet    Only display errors and warnings.\n'
94
 
            '  -v, --verbose  Display more information.\n'
95
71
            '  -h, --help     Show help message.\n'
96
72
            '\n'
97
73
            'See also: bar, foo, gam\n')
98
74
 
99
75
    def test_command_only_additional_see_also(self):
100
76
        class cmd_WithSeeAlso(commands.Command):
101
 
            __doc__ = """A sample command."""
 
77
            """A sample command."""
102
78
        cmd = cmd_WithSeeAlso()
103
79
        helptext = cmd.get_help_text(['gam'])
104
80
        self.assertEndsWith(
105
81
            helptext,
 
82
            '  -v, --verbose  Display more information.\n'
106
83
            '  -q, --quiet    Only display errors and warnings.\n'
107
 
            '  -v, --verbose  Display more information.\n'
108
84
            '  -h, --help     Show help message.\n'
109
85
            '\n'
110
86
            'See also: gam\n')
112
88
    def test_get_help_topic(self):
113
89
        """The help topic for a Command is its name()."""
114
90
        class cmd_foo_bar(commands.Command):
115
 
            __doc__ = """A sample command."""
 
91
            """A sample command."""
116
92
        cmd = cmd_foo_bar()
117
93
        self.assertEqual(cmd.name(), cmd.get_help_topic())
118
94
 
119
95
    def test_formatted_help_text(self):
120
96
        """Help text should be plain text by default."""
121
97
        class cmd_Demo(commands.Command):
122
 
            __doc__ = """A sample command.
123
 
 
 
98
            """A sample command.
 
99
 
124
100
            :Examples:
125
101
                Example 1::
126
 
 
 
102
 
127
103
                    cmd arg1
128
 
 
 
104
 
129
105
                Example 2::
130
 
 
 
106
 
131
107
                    cmd arg2
132
 
 
133
 
                A code block follows.
134
 
 
135
 
                ::
136
 
 
137
 
                    bzr Demo something
138
108
            """
139
109
        cmd = cmd_Demo()
140
110
        helptext = cmd.get_help_text()
141
 
        self.assertEqualDiff('''\
142
 
Purpose: A sample command.
143
 
Usage:   bzr Demo
144
 
 
145
 
Options:
146
 
  --usage        Show usage message and options.
147
 
  -q, --quiet    Only display errors and warnings.
148
 
  -v, --verbose  Display more information.
149
 
  -h, --help     Show help message.
150
 
 
151
 
Examples:
152
 
    Example 1:
153
 
 
154
 
        cmd arg1
155
 
 
156
 
    Example 2:
157
 
 
158
 
        cmd arg2
159
 
 
160
 
    A code block follows.
161
 
 
162
 
        bzr Demo something
163
 
 
164
 
''',
165
 
                                         helptext)
 
111
        self.assertEquals(
 
112
            helptext,
 
113
            'Purpose: A sample command.\n'
 
114
            'Usage:   bzr Demo\n'
 
115
            '\n'
 
116
            'Options:\n'
 
117
            '  -v, --verbose  Display more information.\n'
 
118
            '  -q, --quiet    Only display errors and warnings.\n'
 
119
            '  -h, --help     Show help message.\n'
 
120
            '\n'
 
121
            'Examples:\n'
 
122
            '    Example 1:\n'
 
123
            '\n'
 
124
            '        cmd arg1\n'
 
125
            '\n'
 
126
            '    Example 2:\n'
 
127
            '\n'
 
128
            '        cmd arg2\n'
 
129
            '\n')
166
130
        helptext = cmd.get_help_text(plain=False)
167
 
        self.assertEqualDiff('''\
168
 
:Purpose: A sample command.
169
 
:Usage:   bzr Demo
170
 
 
171
 
:Options:
172
 
  --usage        Show usage message and options.
173
 
  -q, --quiet    Only display errors and warnings.
174
 
  -v, --verbose  Display more information.
175
 
  -h, --help     Show help message.
176
 
 
177
 
:Examples:
178
 
    Example 1::
179
 
 
180
 
        cmd arg1
181
 
 
182
 
    Example 2::
183
 
 
184
 
        cmd arg2
185
 
 
186
 
    A code block follows.
187
 
 
188
 
    ::
189
 
 
190
 
        bzr Demo something
191
 
 
192
 
''',
193
 
                             helptext)
194
 
 
195
 
    def test_concise_help_text(self):
196
 
        """Concise help text excludes the descriptive sections."""
197
 
        class cmd_Demo(commands.Command):
198
 
            __doc__ = """A sample command.
199
 
 
200
 
            Blah blah blah.
201
 
 
202
 
            :Examples:
203
 
                Example 1::
204
 
 
205
 
                    cmd arg1
206
 
            """
207
 
        cmd = cmd_Demo()
208
 
        helptext = cmd.get_help_text()
209
 
        self.assertEqualDiff('''\
210
 
Purpose: A sample command.
211
 
Usage:   bzr Demo
212
 
 
213
 
Options:
214
 
  --usage        Show usage message and options.
215
 
  -q, --quiet    Only display errors and warnings.
216
 
  -v, --verbose  Display more information.
217
 
  -h, --help     Show help message.
218
 
 
219
 
Description:
220
 
  Blah blah blah.
221
 
 
222
 
Examples:
223
 
    Example 1:
224
 
 
225
 
        cmd arg1
226
 
 
227
 
''',
228
 
                             helptext)
229
 
        helptext = cmd.get_help_text(verbose=False)
230
 
        self.assertEqualDiff('''\
231
 
Purpose: A sample command.
232
 
Usage:   bzr Demo
233
 
 
234
 
Options:
235
 
  --usage        Show usage message and options.
236
 
  -q, --quiet    Only display errors and warnings.
237
 
  -v, --verbose  Display more information.
238
 
  -h, --help     Show help message.
239
 
 
240
 
See bzr help Demo for more details and examples.
241
 
 
242
 
''',
243
 
                             helptext)
244
 
 
245
 
    def test_help_custom_section_ordering(self):
246
 
        """Custom descriptive sections should remain in the order given."""
247
 
        class cmd_Demo(commands.Command):
248
 
            __doc__ = """\
249
 
A sample command.
250
 
 
251
 
Blah blah blah.
252
 
 
253
 
:Formats:
254
 
  Interesting stuff about formats.
255
 
 
256
 
:Examples:
257
 
  Example 1::
258
 
 
259
 
    cmd arg1
260
 
 
261
 
:Tips:
262
 
  Clever things to keep in mind.
263
 
"""
264
 
        cmd = cmd_Demo()
265
 
        helptext = cmd.get_help_text()
266
 
        self.assertEqualDiff('''\
267
 
Purpose: A sample command.
268
 
Usage:   bzr Demo
269
 
 
270
 
Options:
271
 
  --usage        Show usage message and options.
272
 
  -q, --quiet    Only display errors and warnings.
273
 
  -v, --verbose  Display more information.
274
 
  -h, --help     Show help message.
275
 
 
276
 
Description:
277
 
  Blah blah blah.
278
 
 
279
 
Formats:
280
 
  Interesting stuff about formats.
281
 
 
282
 
Examples:
283
 
  Example 1:
284
 
 
285
 
    cmd arg1
286
 
 
287
 
Tips:
288
 
  Clever things to keep in mind.
289
 
 
290
 
''',
291
 
                             helptext)
292
 
 
293
 
    def test_help_text_custom_usage(self):
294
 
        """Help text may contain a custom usage section."""
295
 
        class cmd_Demo(commands.Command):
296
 
            __doc__ = """A sample command.
297
 
 
298
 
            :Usage:
299
 
                cmd Demo [opts] args
300
 
 
301
 
                cmd Demo -h
302
 
 
303
 
            Blah blah blah.
304
 
            """
305
 
        cmd = cmd_Demo()
306
 
        helptext = cmd.get_help_text()
307
 
        self.assertEqualDiff('''\
308
 
Purpose: A sample command.
309
 
Usage:
310
 
    cmd Demo [opts] args
311
 
 
312
 
    cmd Demo -h
313
 
 
314
 
 
315
 
Options:
316
 
  --usage        Show usage message and options.
317
 
  -q, --quiet    Only display errors and warnings.
318
 
  -v, --verbose  Display more information.
319
 
  -h, --help     Show help message.
320
 
 
321
 
Description:
322
 
  Blah blah blah.
323
 
 
324
 
''',
325
 
                             helptext)
326
 
 
327
 
 
328
 
class ZzzTranslationsForDoc(ZzzTranslations):
329
 
 
330
 
    _section_pat = re.compile(':\w+:\\n\\s+')
331
 
    _indent_pat = re.compile('\\s+')
332
 
 
333
 
    def zzz(self, s):
334
 
        m = self._section_pat.match(s)
335
 
        if m is None:
336
 
            m = self._indent_pat.match(s)
337
 
        if m:
338
 
            return u'%szz{{%s}}' % (m.group(0), s[m.end():])
339
 
        return u'zz{{%s}}' % s
340
 
 
341
 
 
342
 
class TestCommandHelpI18n(tests.TestCase):
343
 
    """Tests for help on translated commands."""
344
 
 
345
 
    def setUp(self):
346
 
        super(TestCommandHelpI18n, self).setUp()
347
 
        self.overrideAttr(i18n, '_translations', ZzzTranslationsForDoc())
348
 
 
349
 
    def assertCmdHelp(self, expected, cmd):
350
 
        self.assertEqualDiff(textwrap.dedent(expected), cmd.get_help_text())
351
 
 
352
 
    def test_command_help_includes_see_also(self):
353
 
        class cmd_WithSeeAlso(commands.Command):
354
 
            __doc__ = """A sample command."""
355
 
            _see_also = ['foo', 'bar']
356
 
        self.assertCmdHelp('''\
357
 
zz{{:Purpose: zz{{A sample command.}}
358
 
}}zz{{:Usage:   bzr WithSeeAlso
359
 
}}
360
 
zz{{:Options:
361
 
  --usage        zz{{Show usage message and options.}}
362
 
  -q, --quiet    zz{{Only display errors and warnings.}}
363
 
  -v, --verbose  zz{{Display more information.}}
364
 
  -h, --help     zz{{Show help message.}}
365
 
}}
366
 
zz{{:See also: bar, foo}}
367
 
''',
368
 
                           cmd_WithSeeAlso())
369
 
 
370
 
    def test_get_help_text(self):
371
 
        """Commands have a get_help_text method which returns their help."""
372
 
        class cmd_Demo(commands.Command):
373
 
            __doc__ = """A sample command."""
374
 
        self.assertCmdHelp('''\
375
 
zz{{:Purpose: zz{{A sample command.}}
376
 
}}zz{{:Usage:   bzr Demo
377
 
}}
378
 
zz{{:Options:
379
 
  --usage        zz{{Show usage message and options.}}
380
 
  -q, --quiet    zz{{Only display errors and warnings.}}
381
 
  -v, --verbose  zz{{Display more information.}}
382
 
  -h, --help     zz{{Show help message.}}
383
 
}}
384
 
''',
385
 
                           cmd_Demo())
386
 
 
387
 
    def test_command_with_additional_see_also(self):
388
 
        class cmd_WithSeeAlso(commands.Command):
389
 
            __doc__ = """A sample command."""
390
 
            _see_also = ['foo', 'bar']
391
 
        cmd = cmd_WithSeeAlso()
392
 
        helptext = cmd.get_help_text(['gam'])
393
 
        self.assertEndsWith(
394
 
            helptext,'''\
395
 
  -q, --quiet    zz{{Only display errors and warnings.}}
396
 
  -v, --verbose  zz{{Display more information.}}
397
 
  -h, --help     zz{{Show help message.}}
398
 
}}
399
 
zz{{:See also: bar, foo, gam}}
400
 
''')
401
 
 
402
 
    def test_command_only_additional_see_also(self):
403
 
        class cmd_WithSeeAlso(commands.Command):
404
 
            __doc__ = """A sample command."""
405
 
        cmd = cmd_WithSeeAlso()
406
 
        helptext = cmd.get_help_text(['gam'])
407
 
        self.assertEndsWith(
408
 
            helptext, '''\
409
 
zz{{:Options:
410
 
  --usage        zz{{Show usage message and options.}}
411
 
  -q, --quiet    zz{{Only display errors and warnings.}}
412
 
  -v, --verbose  zz{{Display more information.}}
413
 
  -h, --help     zz{{Show help message.}}
414
 
}}
415
 
zz{{:See also: gam}}
416
 
''')
417
 
 
418
 
 
419
 
    def test_help_custom_section_ordering(self):
420
 
        """Custom descriptive sections should remain in the order given."""
421
 
        # The help formatter expect the class name to start with 'cmd_'
422
 
        class cmd_Demo(commands.Command):
423
 
            __doc__ = """A sample command.
424
 
 
425
 
            Blah blah blah.
426
 
 
427
 
            :Formats:
428
 
              Interesting stuff about formats.
429
 
 
430
 
            :Examples:
431
 
              Example 1::
432
 
 
433
 
                cmd arg1
434
 
 
435
 
            :Tips:
436
 
              Clever things to keep in mind.
437
 
            """
438
 
        self.assertCmdHelp('''\
439
 
zz{{:Purpose: zz{{A sample command.}}
440
 
}}zz{{:Usage:   bzr Demo
441
 
}}
442
 
zz{{:Options:
443
 
  --usage        zz{{Show usage message and options.}}
444
 
  -q, --quiet    zz{{Only display errors and warnings.}}
445
 
  -v, --verbose  zz{{Display more information.}}
446
 
  -h, --help     zz{{Show help message.}}
447
 
}}
448
 
Description:
449
 
  zz{{zz{{Blah blah blah.}}
450
 
 
451
 
}}:Formats:
452
 
  zz{{Interesting stuff about formats.}}
453
 
 
454
 
Examples:
455
 
  zz{{Example 1::}}
456
 
 
457
 
    zz{{cmd arg1}}
458
 
 
459
 
Tips:
460
 
  zz{{Clever things to keep in mind.}}
461
 
 
462
 
''',
463
 
                           cmd_Demo())
464
 
 
465
 
    def test_help_text_custom_usage(self):
466
 
        """Help text may contain a custom usage section."""
467
 
        class cmd_Demo(commands.Command):
468
 
            __doc__ = """A sample command.
469
 
 
470
 
            :Usage:
471
 
                cmd Demo [opts] args
472
 
 
473
 
                cmd Demo -h
474
 
 
475
 
            Blah blah blah.
476
 
            """
477
 
        self.assertCmdHelp('''\
478
 
zz{{:Purpose: zz{{A sample command.}}
479
 
}}zz{{:Usage:
480
 
    zz{{cmd Demo [opts] args}}
481
 
 
482
 
    zz{{cmd Demo -h}}
483
 
 
484
 
}}
485
 
zz{{:Options:
486
 
  --usage        zz{{Show usage message and options.}}
487
 
  -q, --quiet    zz{{Only display errors and warnings.}}
488
 
  -v, --verbose  zz{{Display more information.}}
489
 
  -h, --help     zz{{Show help message.}}
490
 
}}
491
 
Description:
492
 
  zz{{zz{{Blah blah blah.}}
493
 
 
494
 
}}
495
 
''',
496
 
                           cmd_Demo())
497
 
 
498
 
 
499
 
class TestHelp(tests.TestCase):
500
 
 
501
 
    def setUp(self):
502
 
        super(TestHelp, self).setUp()
503
 
        commands.install_bzr_command_hooks()
504
 
 
505
 
 
506
 
class TestRegisteredTopic(TestHelp):
 
131
        self.assertEquals(helptext,
 
132
            ':Purpose: A sample command.\n'
 
133
            ':Usage:   bzr Demo\n'
 
134
            '\n'
 
135
            ':Options:\n'
 
136
            '  -v, --verbose  Display more information.\n'
 
137
            '  -q, --quiet    Only display errors and warnings.\n'
 
138
            '  -h, --help     Show help message.\n'
 
139
            '\n'
 
140
            ':Examples:\n'
 
141
            '    Example 1::\n'
 
142
            '\n'
 
143
            '        cmd arg1\n'
 
144
            '\n'
 
145
            '    Example 2::\n'
 
146
            '\n'
 
147
            '        cmd arg2\n'
 
148
            '\n')
 
149
 
 
150
    def test_help_text_custom_usage(self):
 
151
        """Help text may contain a custom usage section."""
 
152
        class cmd_Demo(commands.Command):
 
153
            """A sample command.
 
154
 
 
155
            :Usage:
 
156
                cmd Demo [opts] args
 
157
 
 
158
                cmd Demo -h
 
159
 
 
160
            Blah blah blah.
 
161
            """
 
162
        cmd = cmd_Demo()
 
163
        helptext = cmd.get_help_text()
 
164
        self.assertEquals(helptext,
 
165
            'Purpose: A sample command.\n'
 
166
            'Usage:\n'
 
167
            '    cmd Demo [opts] args\n'
 
168
            '\n'
 
169
            '    cmd Demo -h\n'
 
170
            '\n'
 
171
            '\n'
 
172
            'Options:\n'
 
173
            '  -v, --verbose  Display more information.\n'
 
174
            '  -q, --quiet    Only display errors and warnings.\n'
 
175
            '  -h, --help     Show help message.\n'
 
176
            '\n'
 
177
            'Description:\n'
 
178
            '  Blah blah blah.\n\n')
 
179
 
 
180
 
 
181
class TestRegisteredTopic(tests.TestCase):
507
182
    """Tests for the RegisteredTopic class."""
508
183
 
509
184
    def test_contruct(self):
510
185
        """Construction takes the help topic name for the registered item."""
511
 
        # validate our test
 
186
        # validate our test 
512
187
        self.assertTrue('basic' in help_topics.topic_registry)
513
188
        topic = help_topics.RegisteredTopic('basic')
514
189
        self.assertEqual('basic', topic.topic)
515
190
 
516
191
    def test_get_help_text(self):
517
 
        """RegisteredTopic returns the get_detail results for get_help_text."""
 
192
        """A RegisteredTopic returns the get_detail results for get_help_text."""
518
193
        topic = help_topics.RegisteredTopic('commands')
519
194
        self.assertEqual(help_topics.topic_registry.get_detail('commands'),
520
 
                         topic.get_help_text())
 
195
            topic.get_help_text())
521
196
 
522
197
    def test_get_help_text_with_additional_see_also(self):
523
198
        topic = help_topics.RegisteredTopic('commands')
528
203
 
529
204
    def test_get_help_text_loaded_from_file(self):
530
205
        # Pick a known topic stored in an external file
531
 
        topic = help_topics.RegisteredTopic('authentication')
 
206
        topic = help_topics.RegisteredTopic('hooks')
532
207
        self.assertStartsWith(topic.get_help_text(),
533
 
            'Authentication Settings\n'
534
 
            '=======================\n'
 
208
            'Hooks\n'
 
209
            '=====\n'
535
210
            '\n')
536
211
 
537
212
    def test_get_help_topic(self):
538
 
        """The help topic for RegisteredTopic is its topic from construction."""
 
213
        """The help topic for a RegisteredTopic is its topic from construction."""
539
214
        topic = help_topics.RegisteredTopic('foobar')
540
215
        self.assertEqual('foobar', topic.get_help_topic())
541
216
        topic = help_topics.RegisteredTopic('baz')
542
217
        self.assertEqual('baz', topic.get_help_topic())
543
218
 
544
219
 
545
 
class TestTopicIndex(TestHelp):
 
220
class TestTopicIndex(tests.TestCase):
546
221
    """Tests for the HelpTopicIndex class."""
547
222
 
548
223
    def test_default_constructable(self):
575
250
        self.assertEqual('', index.prefix)
576
251
 
577
252
 
578
 
class TestConfigOptionIndex(TestHelp):
579
 
    """Tests for the HelpCommandIndex class."""
580
 
 
581
 
    def setUp(self):
582
 
        super(TestConfigOptionIndex, self).setUp()
583
 
        self.index = help_topics.ConfigOptionHelpIndex()
584
 
 
585
 
    def test_get_topics_None(self):
586
 
        """Searching for None returns an empty list."""
587
 
        self.assertEqual([], self.index.get_topics(None))
588
 
 
589
 
    def test_get_topics_no_topic(self):
590
 
        self.assertEqual([], self.index.get_topics('nothing by this name'))
591
 
 
592
 
    def test_prefix(self):
593
 
        self.assertEqual('configuration/', self.index.prefix)
594
 
 
595
 
    def test_get_topic_with_prefix(self):
596
 
        topics = self.index.get_topics('configuration/default_format')
597
 
        self.assertLength(1, topics)
598
 
        opt = topics[0]
599
 
        self.assertIsInstance(opt, config.Option)
600
 
        self.assertEqual('default_format', opt.name)
601
 
 
602
 
 
603
 
class TestCommandIndex(TestHelp):
 
253
class TestCommandIndex(tests.TestCase):
604
254
    """Tests for the HelpCommandIndex class."""
605
255
 
606
256
    def test_default_constructable(self):
642
292
    def test_default_search_path(self):
643
293
        """The default search path should include internal indexs."""
644
294
        indices = help.HelpIndices()
645
 
        self.assertEqual(4, len(indices.search_path))
 
295
        self.assertEqual(3, len(indices.search_path))
646
296
        # help topics should be searched in first.
647
297
        self.assertIsInstance(indices.search_path[0],
648
 
                              help_topics.HelpTopicIndex)
 
298
            help_topics.HelpTopicIndex)
649
299
        # with commands being search second.
650
300
        self.assertIsInstance(indices.search_path[1],
651
 
                              commands.HelpCommandIndex)
652
 
        # plugins are a third index.
 
301
            commands.HelpCommandIndex)
 
302
        # and plugins are a third index.
653
303
        self.assertIsInstance(indices.search_path[2],
654
 
                              plugin.PluginsHelpIndex)
655
 
        # config options are a fourth index
656
 
        self.assertIsInstance(indices.search_path[3],
657
 
                              help_topics.ConfigOptionHelpIndex)
 
304
            plugin.PluginsHelpIndex)
658
305
 
659
306
    def test_search_for_unknown_topic_raises(self):
660
307
        """Searching for an unknown topic should raise NoHelpTopic."""