/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 breezy/tests/test_help.py

  • Committer: Jelmer Vernooij
  • Date: 2018-07-08 14:45:27 UTC
  • mto: This revision was merged to the branch mainline in revision 7036.
  • Revision ID: jelmer@jelmer.uk-20180708144527-codhlvdcdg9y0nji
Fix a bunch of merge tests.

Show diffs side-by-side

added added

removed removed

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