~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Jelmer Vernooij
  • Date: 2010-04-30 11:03:59 UTC
  • mto: This revision was merged to the branch mainline in revision 5197.
  • Revision ID: jelmer@samba.org-20100430110359-ow3e3grh7sxy93pa
Remove more unused imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2011 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
16
16
 
17
17
"""Unit tests for the bzrlib.help module."""
18
18
 
 
19
from cStringIO import StringIO
 
20
 
19
21
from bzrlib import (
20
22
    builtins,
21
23
    commands,
39
41
 
40
42
    def test_command_help_includes_see_also(self):
41
43
        class cmd_WithSeeAlso(commands.Command):
42
 
            __doc__ = """A sample command."""
 
44
            """A sample command."""
43
45
            _see_also = ['foo', 'bar']
44
46
        cmd = cmd_WithSeeAlso()
45
47
        helptext = cmd.get_help_text()
54
56
    def test_get_help_text(self):
55
57
        """Commands have a get_help_text method which returns their help."""
56
58
        class cmd_Demo(commands.Command):
57
 
            __doc__ = """A sample command."""
 
59
            """A sample command."""
58
60
        cmd = cmd_Demo()
59
61
        helptext = cmd.get_help_text()
60
62
        self.assertStartsWith(helptext,
65
67
 
66
68
    def test_command_with_additional_see_also(self):
67
69
        class cmd_WithSeeAlso(commands.Command):
68
 
            __doc__ = """A sample command."""
 
70
            """A sample command."""
69
71
            _see_also = ['foo', 'bar']
70
72
        cmd = cmd_WithSeeAlso()
71
73
        helptext = cmd.get_help_text(['gam'])
79
81
 
80
82
    def test_command_only_additional_see_also(self):
81
83
        class cmd_WithSeeAlso(commands.Command):
82
 
            __doc__ = """A sample command."""
 
84
            """A sample command."""
83
85
        cmd = cmd_WithSeeAlso()
84
86
        helptext = cmd.get_help_text(['gam'])
85
87
        self.assertEndsWith(
93
95
    def test_get_help_topic(self):
94
96
        """The help topic for a Command is its name()."""
95
97
        class cmd_foo_bar(commands.Command):
96
 
            __doc__ = """A sample command."""
 
98
            """A sample command."""
97
99
        cmd = cmd_foo_bar()
98
100
        self.assertEqual(cmd.name(), cmd.get_help_topic())
99
101
 
100
102
    def test_formatted_help_text(self):
101
103
        """Help text should be plain text by default."""
102
104
        class cmd_Demo(commands.Command):
103
 
            __doc__ = """A sample command.
 
105
            """A sample command.
104
106
 
105
107
            :Examples:
106
108
                Example 1::
110
112
                Example 2::
111
113
 
112
114
                    cmd arg2
113
 
 
114
 
                A code block follows.
115
 
 
116
 
                ::
117
 
 
118
 
                    bzr Demo something
119
115
            """
120
116
        cmd = cmd_Demo()
121
117
        helptext = cmd.get_help_text()
138
134
            '    Example 2:\n'
139
135
            '\n'
140
136
            '        cmd arg2\n'
141
 
            '\n'
142
 
            '    A code block follows.\n'
143
 
            '\n'
144
 
            '        bzr Demo something\n'
145
137
            '\n')
146
138
        helptext = cmd.get_help_text(plain=False)
147
139
        self.assertEquals(helptext,
162
154
            '    Example 2::\n'
163
155
            '\n'
164
156
            '        cmd arg2\n'
165
 
            '\n'
166
 
            '    A code block follows.\n'
167
 
            '\n'
168
 
            '    ::\n'
169
 
            '\n'
170
 
            '        bzr Demo something\n'
171
157
            '\n')
172
158
 
173
159
    def test_concise_help_text(self):
174
160
        """Concise help text excludes the descriptive sections."""
175
161
        class cmd_Demo(commands.Command):
176
 
            __doc__ = """A sample command.
 
162
            """A sample command.
177
163
 
178
164
            Blah blah blah.
179
165
 
220
206
    def test_help_custom_section_ordering(self):
221
207
        """Custom descriptive sections should remain in the order given."""
222
208
        class cmd_Demo(commands.Command):
223
 
            __doc__ = """A sample command.
 
209
            """A sample command.
224
210
 
225
211
            Blah blah blah.
226
212
 
266
252
    def test_help_text_custom_usage(self):
267
253
        """Help text may contain a custom usage section."""
268
254
        class cmd_Demo(commands.Command):
269
 
            __doc__ = """A sample command.
 
255
            """A sample command.
270
256
 
271
257
            :Usage:
272
258
                cmd Demo [opts] args