13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Unit tests for the bzrlib.help module."""
32
class TestHelp(tests.TestCase):
35
tests.TestCase.setUp(self)
36
commands.install_bzr_command_hooks()
39
32
class TestCommandHelp(tests.TestCase):
40
33
"""Tests for help on commands."""
121
114
'Usage: bzr Demo\n'
124
' --usage Show usage message and options.\n'
125
117
' -v, --verbose Display more information.\n'
126
118
' -q, --quiet Only display errors and warnings.\n'
127
119
' -h, --help Show help message.\n'
141
133
':Usage: bzr Demo\n'
144
' --usage Show usage message and options.\n'
145
136
' -v, --verbose Display more information.\n'
146
137
' -q, --quiet Only display errors and warnings.\n'
147
138
' -h, --help Show help message.\n'
159
def test_concise_help_text(self):
160
"""Concise help text excludes the descriptive sections."""
161
class cmd_Demo(commands.Command):
172
helptext = cmd.get_help_text()
173
self.assertEqualDiff(
175
'Purpose: A sample command.\n'
179
' --usage Show usage message and options.\n'
180
' -v, --verbose Display more information.\n'
181
' -q, --quiet Only display errors and warnings.\n'
182
' -h, --help Show help message.\n'
192
helptext = cmd.get_help_text(verbose=False)
193
self.assertEquals(helptext,
194
'Purpose: A sample command.\n'
198
' --usage Show usage message and options.\n'
199
' -v, --verbose Display more information.\n'
200
' -q, --quiet Only display errors and warnings.\n'
201
' -h, --help Show help message.\n'
203
'See bzr help Demo for more details and examples.\n'
206
def test_help_custom_section_ordering(self):
207
"""Custom descriptive sections should remain in the order given."""
208
class cmd_Demo(commands.Command):
214
Interesting stuff about formats.
222
Clever things to keep in mind.
225
helptext = cmd.get_help_text()
226
self.assertEqualDiff(
228
'Purpose: A sample command.\n'
232
' --usage Show usage message and options.\n'
233
' -v, --verbose Display more information.\n'
234
' -q, --quiet Only display errors and warnings.\n'
235
' -h, --help Show help message.\n'
241
' Interesting stuff about formats.\n'
249
' Clever things to keep in mind.\n'
252
150
def test_help_text_custom_usage(self):
253
151
"""Help text may contain a custom usage section."""
254
152
class cmd_Demo(commands.Command):
275
' --usage Show usage message and options.\n'
276
173
' -v, --verbose Display more information.\n'
277
174
' -q, --quiet Only display errors and warnings.\n'
278
175
' -h, --help Show help message.\n'
307
204
def test_get_help_text_loaded_from_file(self):
308
205
# Pick a known topic stored in an external file
309
topic = help_topics.RegisteredTopic('authentication')
206
topic = help_topics.RegisteredTopic('hooks')
310
207
self.assertStartsWith(topic.get_help_text(),
311
'Authentication Settings\n'
312
'=======================\n'
315
212
def test_get_help_topic(self):
320
217
self.assertEqual('baz', topic.get_help_topic())
323
class TestTopicIndex(TestHelp):
220
class TestTopicIndex(tests.TestCase):
324
221
"""Tests for the HelpTopicIndex class."""
326
223
def test_default_constructable(self):
353
250
self.assertEqual('', index.prefix)
356
class TestCommandIndex(TestHelp):
253
class TestCommandIndex(tests.TestCase):
357
254
"""Tests for the HelpCommandIndex class."""
359
256
def test_default_constructable(self):