281
299
' Blah blah blah.\n\n')
302
class ZzzTranslationsForDoc(ZzzTranslations):
304
_section_pat = re.compile(':\w+:\\n\\s+')
305
_indent_pat = re.compile('\\s+')
308
m = self._section_pat.match(s)
310
m = self._indent_pat.match(s)
312
return u'%szz{{%s}}' % (m.group(0), s[m.end():])
313
return u'zz{{%s}}' % s
316
class TestCommandHelpI18n(tests.TestCase):
317
"""Tests for help on translated commands."""
320
super(TestCommandHelpI18n, self).setUp()
321
self.overrideAttr(i18n, '_translation', ZzzTranslationsForDoc())
324
def test_command_help_includes_see_also(self):
325
class cmd_WithSeeAlso(commands.Command):
326
__doc__ = """A sample command."""
327
_see_also = ['foo', 'bar']
328
cmd = cmd_WithSeeAlso()
329
helptext = cmd.get_help_text()
332
' -v, --verbose zz{{Display more information.}}\n'
333
' -q, --quiet zz{{Only display errors and warnings.}}\n'
334
' -h, --help zz{{Show help message.}}\n'
336
'zz{{:See also: bar, foo}}\n')
338
def test_get_help_text(self):
339
"""Commands have a get_help_text method which returns their help."""
340
class cmd_Demo(commands.Command):
341
__doc__ = """A sample command."""
343
helptext = cmd.get_help_text()
344
self.assertStartsWith(helptext,
345
'zz{{:Purpose: zz{{A sample command.}}}}\n'
346
'zz{{:Usage: bzr Demo}}\n')
347
self.assertEndsWith(helptext,
348
' -h, --help zz{{Show help message.}}\n}}\n')
350
def test_command_with_additional_see_also(self):
351
class cmd_WithSeeAlso(commands.Command):
352
__doc__ = """A sample command."""
353
_see_also = ['foo', 'bar']
354
cmd = cmd_WithSeeAlso()
355
helptext = cmd.get_help_text(['gam'])
358
' -v, --verbose zz{{Display more information.}}\n'
359
' -q, --quiet zz{{Only display errors and warnings.}}\n'
360
' -h, --help zz{{Show help message.}}\n'
362
'zz{{:See also: bar, foo, gam}}\n')
364
def test_command_only_additional_see_also(self):
365
class cmd_WithSeeAlso(commands.Command):
366
__doc__ = """A sample command."""
367
cmd = cmd_WithSeeAlso()
368
helptext = cmd.get_help_text(['gam'])
372
' --usage zz{{Show usage message and options.}}\n'
373
' -v, --verbose zz{{Display more information.}}\n'
374
' -q, --quiet zz{{Only display errors and warnings.}}\n'
375
' -h, --help zz{{Show help message.}}\n'
377
'zz{{:See also: gam}}\n')
380
def test_help_custom_section_ordering(self):
381
"""Custom descriptive sections should remain in the order given."""
382
class cmd_Demo(commands.Command):
383
__doc__ = """A sample command.
388
Interesting stuff about formats.
396
Clever things to keep in mind.
399
helptext = cmd.get_help_text()
400
self.assertEqualDiff(
402
'zz{{:Purpose: zz{{A sample command.}}}}\n'
403
'zz{{:Usage: bzr Demo}}\n'
406
' --usage zz{{Show usage message and options.}}\n'
407
' -v, --verbose zz{{Display more information.}}\n'
408
' -q, --quiet zz{{Only display errors and warnings.}}\n'
409
' -h, --help zz{{Show help message.}}\n'
412
' zz{{zz{{Blah blah blah.}}}}\n'
415
' zz{{Interesting stuff about formats.}}\n'
418
' zz{{Example 1::}}\n'
423
' zz{{Clever things to keep in mind.}}\n'
426
def test_help_text_custom_usage(self):
427
"""Help text may contain a custom usage section."""
428
class cmd_Demo(commands.Command):
429
__doc__ = """A sample command.
439
helptext = cmd.get_help_text()
440
self.assertEquals(helptext,
441
'zz{{:Purpose: zz{{A sample command.}}}}\n'
443
' zz{{cmd Demo [opts] args}}\n'
445
' zz{{cmd Demo -h}}\n'
449
' --usage zz{{Show usage message and options.}}\n'
450
' -v, --verbose zz{{Display more information.}}\n'
451
' -q, --quiet zz{{Only display errors and warnings.}}\n'
452
' -h, --help zz{{Show help message.}}\n'
455
' zz{{zz{{Blah blah blah.}}}}\n\n')
284
458
class TestRegisteredTopic(TestHelp):
285
459
"""Tests for the RegisteredTopic class."""