~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-14 03:59:22 UTC
  • mto: (2733.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2734.
  • Revision ID: ian.clatworthy@internode.on.net-20070814035922-siavg542cwvkf4r5
Fix pretty doc generation so works for all html docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
            """A sample command."""
51
51
        cmd = cmd_Demo()
52
52
        helptext = cmd.get_help_text()
53
 
        self.assertStartsWith(helptext, 'usage: bzr Demo')
54
 
        self.assertEndsWith(helptext, 'Show help message.\n')
 
53
        self.assertStartsWith(helptext,
 
54
            'Purpose: A sample command.\n'
 
55
            'Usage:   bzr Demo')
 
56
        self.assertEndsWith(helptext, 'Show help message.\n\n')
55
57
 
56
58
    def test_command_with_additional_see_also(self):
57
59
        class cmd_WithSeeAlso(commands.Command):
82
84
            """A sample command."""
83
85
        cmd = cmd_foo_bar()
84
86
        self.assertEqual(cmd.name(), cmd.get_help_topic())
85
 
    
 
87
 
 
88
    def test_formatted_help_text(self):
 
89
        """Help text should be plain text by default."""
 
90
        class cmd_Demo(commands.Command):
 
91
            """A sample command.
 
92
 
 
93
            :Examples:
 
94
                Example 1::
 
95
 
 
96
                    cmd arg1
 
97
 
 
98
                Example 2::
 
99
 
 
100
                    cmd arg2
 
101
            """
 
102
        cmd = cmd_Demo()
 
103
        helptext = cmd.get_help_text()
 
104
        self.assertEquals(
 
105
            helptext,
 
106
            'Purpose: A sample command.\n'
 
107
            'Usage:   bzr Demo\n'
 
108
            '\n'
 
109
            'Options:\n'
 
110
            '  -h, --help  Show help message.\n'
 
111
            '\n'
 
112
            'Examples:\n'
 
113
            '    Example 1:\n'
 
114
            '\n'
 
115
            '        cmd arg1\n'
 
116
            '\n'
 
117
            '    Example 2:\n'
 
118
            '\n'
 
119
            '        cmd arg2\n'
 
120
            '\n')
 
121
        helptext = cmd.get_help_text(plain=False)
 
122
        self.assertEquals(helptext,
 
123
            ':Purpose: A sample command.\n'
 
124
            ':Usage:   bzr Demo\n'
 
125
            '\n'
 
126
            ':Options:\n'
 
127
            '  -h, --help  Show help message.\n'
 
128
            '\n'
 
129
            ':Examples:\n'
 
130
            '    Example 1::\n'
 
131
            '\n'
 
132
            '        cmd arg1\n'
 
133
            '\n'
 
134
            '    Example 2::\n'
 
135
            '\n'
 
136
            '        cmd arg2\n'
 
137
            '\n')
 
138
 
 
139
    def test_help_text_custom_usage(self):
 
140
        """Help text may contain a custom usage section."""
 
141
        class cmd_Demo(commands.Command):
 
142
            """A sample command.
 
143
 
 
144
            :Usage:
 
145
                cmd Demo [opts] args
 
146
 
 
147
                cmd Demo -h
 
148
 
 
149
            Blah blah blah.
 
150
            """
 
151
        cmd = cmd_Demo()
 
152
        helptext = cmd.get_help_text()
 
153
        self.assertEquals(helptext,
 
154
            'Purpose: A sample command.\n'
 
155
            'Usage:\n'
 
156
            '    cmd Demo [opts] args\n'
 
157
            '\n'
 
158
            '    cmd Demo -h\n'
 
159
            '\n'
 
160
            '\n'
 
161
            'Options:\n'
 
162
            '  -h, --help  Show help message.\n'
 
163
            '\n'
 
164
            'Description:\n'
 
165
            '  Blah blah blah.\n\n')
 
166
 
86
167
 
87
168
class TestRegisteredTopic(tests.TestCase):
88
169
    """Tests for the RegisteredTopic class."""