/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-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
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.
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_'
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)