~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: INADA Naoki
  • Date: 2011-05-18 06:01:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5894.
  • Revision ID: songofacandy@gmail.com-20110518060108-86t2kffcrzu0nf6i
Update Japanese docs.

Show diffs side-by-side

added added

removed removed

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