/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: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    def test_no_help_topic(self):
40
40
        error = help.NoHelpTopic("topic")
41
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))
 
42
                             "Please use 'brz help topics' to obtain a list of topics.",
 
43
                             str(error))
44
44
 
45
45
 
46
46
class TestCommandHelp(tests.TestCase):
86
86
        cmd = cmd_Demo()
87
87
        helptext = cmd.get_help_text()
88
88
        self.assertStartsWith(helptext,
89
 
            'Purpose: A sample command.\n'
90
 
            'Usage:   brz Demo')
 
89
                              'Purpose: A sample command.\n'
 
90
                              'Usage:   brz Demo')
91
91
        self.assertEndsWith(helptext,
92
 
            '  -v, --verbose  Display more information.\n\n')
 
92
                            '  -v, --verbose  Display more information.\n\n')
93
93
 
94
94
    def test_command_with_additional_see_also(self):
95
95
        class cmd_WithSeeAlso(commands.Command):
170
170
        brz Demo something
171
171
 
172
172
''',
173
 
                                         helptext)
 
173
                             helptext)
174
174
        helptext = cmd.get_help_text(plain=False)
175
175
        self.assertEqualDiff('''\
176
176
:Purpose: A sample command.
204
204
        """Concise help text excludes the descriptive sections."""
205
205
        class cmd_Demo(commands.Command):
206
206
            __doc__ = """A sample command.
207
 
 
 
207
 
208
208
            Blah blah blah.
209
209
 
210
210
            :Examples:
211
211
                Example 1::
212
 
 
 
212
 
213
213
                    cmd arg1
214
214
            """
215
215
        cmd = cmd_Demo()
424
424
zz{{:See also: gam}}
425
425
''')
426
426
 
427
 
 
428
427
    def test_help_custom_section_ordering(self):
429
428
        """Custom descriptive sections should remain in the order given."""
430
429
        # The help formatter expect the class name to start with 'cmd_'
431
430
        class cmd_Demo(commands.Command):
432
431
            __doc__ = """A sample command.
433
 
 
 
432
 
434
433
            Blah blah blah.
435
434
 
436
435
            :Formats:
438
437
 
439
438
            :Examples:
440
439
              Example 1::
441
 
 
 
440
 
442
441
                cmd arg1
443
442
 
444
443
            :Tips:
456
455
}}
457
456
Description:
458
457
  zz{{zz{{Blah blah blah.}}
459
 
 
 
458
 
460
459
}}:Formats:
461
460
  zz{{Interesting stuff about formats.}}
462
 
 
 
461
 
463
462
Examples:
464
463
  zz{{Example 1::}}
465
 
 
 
464
 
466
465
    zz{{cmd arg1}}
467
 
 
 
466
 
468
467
Tips:
469
468
  zz{{Clever things to keep in mind.}}
470
 
 
 
469
 
471
470
''',
472
471
                           cmd_Demo())
473
472
 
539
538
        # Pick a known topic stored in an external file
540
539
        topic = help_topics.RegisteredTopic('authentication')
541
540
        self.assertStartsWith(topic.get_help_text(),
542
 
            'Authentication Settings\n'
543
 
            '=======================\n'
544
 
            '\n')
 
541
                              'Authentication Settings\n'
 
542
                              '=======================\n'
 
543
                              '\n')
545
544
 
546
545
    def test_get_help_topic(self):
547
546
        """The help topic for RegisteredTopic is its topic from construction."""
675
674
    def test_search_calls_get_topic(self):
676
675
        """Searching should call get_topics in all indexes in order."""
677
676
        calls = []
 
677
 
678
678
        class RecordingIndex(object):
679
679
            def __init__(self, name):
680
680
                self.prefix = name
 
681
 
681
682
            def get_topics(self, topic):
682
683
                calls.append(('get_topics', self.prefix, topic))
683
684
                return ['something']
705
706
            def __init__(self, prefix, search_result):
706
707
                self.prefix = prefix
707
708
                self.result = search_result
 
709
 
708
710
            def get_topics(self, topic):
709
711
                return self.result
710
712
        index = help.HelpIndices()
712
714
        index_two = CannedIndex('2', ['b', 'c'])
713
715
        index.search_path = [index_one, index_two]
714
716
        self.assertEqual([(index_one, 'a'), (index_two, 'b'), (index_two, 'c')],
715
 
            index.search(None))
 
717
                         index.search(None))
716
718
 
717
719
    def test_search_checks_for_duplicate_prefixes(self):
718
720
        """Its an error when there are multiple indices with the same prefix."""
719
721
        indices = help.HelpIndices()
720
722
        indices.search_path = [help_topics.HelpTopicIndex(),
721
 
            help_topics.HelpTopicIndex()]
 
723
                               help_topics.HelpTopicIndex()]
722
724
        self.assertRaises(errors.DuplicateHelpPrefix, indices.search, None)