~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-23 11:11:22 UTC
  • mfrom: (5177.1.1 integration2)
  • Revision ID: pqm@pqm.ubuntu.com-20100423111122-a5zc2qm7v9qrcxmf
(vila, for gz) Manually assign docstrings to command objects,
        so that they work with python -OO

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007-2010 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
41
41
 
42
42
    def test_command_help_includes_see_also(self):
43
43
        class cmd_WithSeeAlso(commands.Command):
44
 
            """A sample command."""
 
44
            __doc__ = """A sample command."""
45
45
            _see_also = ['foo', 'bar']
46
46
        cmd = cmd_WithSeeAlso()
47
47
        helptext = cmd.get_help_text()
56
56
    def test_get_help_text(self):
57
57
        """Commands have a get_help_text method which returns their help."""
58
58
        class cmd_Demo(commands.Command):
59
 
            """A sample command."""
 
59
            __doc__ = """A sample command."""
60
60
        cmd = cmd_Demo()
61
61
        helptext = cmd.get_help_text()
62
62
        self.assertStartsWith(helptext,
67
67
 
68
68
    def test_command_with_additional_see_also(self):
69
69
        class cmd_WithSeeAlso(commands.Command):
70
 
            """A sample command."""
 
70
            __doc__ = """A sample command."""
71
71
            _see_also = ['foo', 'bar']
72
72
        cmd = cmd_WithSeeAlso()
73
73
        helptext = cmd.get_help_text(['gam'])
81
81
 
82
82
    def test_command_only_additional_see_also(self):
83
83
        class cmd_WithSeeAlso(commands.Command):
84
 
            """A sample command."""
 
84
            __doc__ = """A sample command."""
85
85
        cmd = cmd_WithSeeAlso()
86
86
        helptext = cmd.get_help_text(['gam'])
87
87
        self.assertEndsWith(
95
95
    def test_get_help_topic(self):
96
96
        """The help topic for a Command is its name()."""
97
97
        class cmd_foo_bar(commands.Command):
98
 
            """A sample command."""
 
98
            __doc__ = """A sample command."""
99
99
        cmd = cmd_foo_bar()
100
100
        self.assertEqual(cmd.name(), cmd.get_help_topic())
101
101
 
102
102
    def test_formatted_help_text(self):
103
103
        """Help text should be plain text by default."""
104
104
        class cmd_Demo(commands.Command):
105
 
            """A sample command.
 
105
            __doc__ = """A sample command.
106
106
 
107
107
            :Examples:
108
108
                Example 1::
159
159
    def test_concise_help_text(self):
160
160
        """Concise help text excludes the descriptive sections."""
161
161
        class cmd_Demo(commands.Command):
162
 
            """A sample command.
 
162
            __doc__ = """A sample command.
163
163
 
164
164
            Blah blah blah.
165
165
 
206
206
    def test_help_custom_section_ordering(self):
207
207
        """Custom descriptive sections should remain in the order given."""
208
208
        class cmd_Demo(commands.Command):
209
 
            """A sample command.
 
209
            __doc__ = """A sample command.
210
210
 
211
211
            Blah blah blah.
212
212
 
252
252
    def test_help_text_custom_usage(self):
253
253
        """Help text may contain a custom usage section."""
254
254
        class cmd_Demo(commands.Command):
255
 
            """A sample command.
 
255
            __doc__ = """A sample command.
256
256
 
257
257
            :Usage:
258
258
                cmd Demo [opts] args