~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

fix NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
        helptext = cmd.get_help_text()
41
41
        self.assertEndsWith(
42
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'
 
43
            '  -h, --help  show help message\n'
46
44
            '\n'
47
45
            'See also: bar, foo\n')
48
46
 
52
50
            """A sample command."""
53
51
        cmd = cmd_Demo()
54
52
        helptext = cmd.get_help_text()
55
 
        self.assertStartsWith(helptext,
56
 
            'Purpose: A sample command.\n'
57
 
            'Usage:   bzr Demo')
58
 
        self.assertEndsWith(helptext,
59
 
            '  -h, --help     Show help message.\n\n')
 
53
        self.assertStartsWith(helptext, 'usage: bzr Demo')
 
54
        self.assertEndsWith(helptext, 'show help message\n')
60
55
 
61
56
    def test_command_with_additional_see_also(self):
62
57
        class cmd_WithSeeAlso(commands.Command):
66
61
        helptext = cmd.get_help_text(['gam'])
67
62
        self.assertEndsWith(
68
63
            helptext,
69
 
            '  -v, --verbose  Display more information.\n'
70
 
            '  -q, --quiet    Only display errors and warnings.\n'
71
 
            '  -h, --help     Show help message.\n'
 
64
            '  -h, --help  show help message\n'
72
65
            '\n'
73
66
            'See also: bar, foo, gam\n')
74
67
 
79
72
        helptext = cmd.get_help_text(['gam'])
80
73
        self.assertEndsWith(
81
74
            helptext,
82
 
            '  -v, --verbose  Display more information.\n'
83
 
            '  -q, --quiet    Only display errors and warnings.\n'
84
 
            '  -h, --help     Show help message.\n'
 
75
            '  -h, --help  show help message\n'
85
76
            '\n'
86
77
            'See also: gam\n')
87
78
 
91
82
            """A sample command."""
92
83
        cmd = cmd_foo_bar()
93
84
        self.assertEqual(cmd.name(), cmd.get_help_topic())
94
 
 
95
 
    def test_formatted_help_text(self):
96
 
        """Help text should be plain text by default."""
97
 
        class cmd_Demo(commands.Command):
98
 
            """A sample command.
99
 
 
100
 
            :Examples:
101
 
                Example 1::
102
 
 
103
 
                    cmd arg1
104
 
 
105
 
                Example 2::
106
 
 
107
 
                    cmd arg2
108
 
            """
109
 
        cmd = cmd_Demo()
110
 
        helptext = cmd.get_help_text()
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')
130
 
        helptext = cmd.get_help_text(plain=False)
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
 
 
 
85
    
180
86
 
181
87
class TestRegisteredTopic(tests.TestCase):
182
88
    """Tests for the RegisteredTopic class."""
201
107
            '\n'
202
108
            'See also: bar, foo\n')
203
109
 
204
 
    def test_get_help_text_loaded_from_file(self):
205
 
        # Pick a known topic stored in an external file
206
 
        topic = help_topics.RegisteredTopic('hooks')
207
 
        self.assertStartsWith(topic.get_help_text(),
208
 
            'Hooks\n'
209
 
            '=====\n'
210
 
            '\n')
211
 
 
212
110
    def test_get_help_topic(self):
213
111
        """The help topic for a RegisteredTopic is its topic from construction."""
214
112
        topic = help_topics.RegisteredTopic('foobar')