~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-28 10:33:44 UTC
  • mfrom: (5171.2.3 401599-strict-warnings)
  • mto: This revision was merged to the branch mainline in revision 5191.
  • Revision ID: v.ladeuil+lp@free.fr-20100428103344-e32qf3cn1avdd2cb
Don't mention --no-strict when we just issue the warning about unclean trees

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
29
29
    )
30
30
 
31
31
 
 
32
class TestHelp(tests.TestCase):
 
33
 
 
34
    def setUp(self):
 
35
        tests.TestCase.setUp(self)
 
36
        commands.install_bzr_command_hooks()
 
37
 
 
38
 
32
39
class TestCommandHelp(tests.TestCase):
33
40
    """Tests for help on commands."""
34
41
 
35
42
    def test_command_help_includes_see_also(self):
36
43
        class cmd_WithSeeAlso(commands.Command):
37
 
            """A sample command."""
 
44
            __doc__ = """A sample command."""
38
45
            _see_also = ['foo', 'bar']
39
46
        cmd = cmd_WithSeeAlso()
40
47
        helptext = cmd.get_help_text()
49
56
    def test_get_help_text(self):
50
57
        """Commands have a get_help_text method which returns their help."""
51
58
        class cmd_Demo(commands.Command):
52
 
            """A sample command."""
 
59
            __doc__ = """A sample command."""
53
60
        cmd = cmd_Demo()
54
61
        helptext = cmd.get_help_text()
55
62
        self.assertStartsWith(helptext,
60
67
 
61
68
    def test_command_with_additional_see_also(self):
62
69
        class cmd_WithSeeAlso(commands.Command):
63
 
            """A sample command."""
 
70
            __doc__ = """A sample command."""
64
71
            _see_also = ['foo', 'bar']
65
72
        cmd = cmd_WithSeeAlso()
66
73
        helptext = cmd.get_help_text(['gam'])
74
81
 
75
82
    def test_command_only_additional_see_also(self):
76
83
        class cmd_WithSeeAlso(commands.Command):
77
 
            """A sample command."""
 
84
            __doc__ = """A sample command."""
78
85
        cmd = cmd_WithSeeAlso()
79
86
        helptext = cmd.get_help_text(['gam'])
80
87
        self.assertEndsWith(
88
95
    def test_get_help_topic(self):
89
96
        """The help topic for a Command is its name()."""
90
97
        class cmd_foo_bar(commands.Command):
91
 
            """A sample command."""
 
98
            __doc__ = """A sample command."""
92
99
        cmd = cmd_foo_bar()
93
100
        self.assertEqual(cmd.name(), cmd.get_help_topic())
94
101
 
95
102
    def test_formatted_help_text(self):
96
103
        """Help text should be plain text by default."""
97
104
        class cmd_Demo(commands.Command):
98
 
            """A sample command.
 
105
            __doc__ = """A sample command.
99
106
 
100
107
            :Examples:
101
108
                Example 1::
152
159
    def test_concise_help_text(self):
153
160
        """Concise help text excludes the descriptive sections."""
154
161
        class cmd_Demo(commands.Command):
155
 
            """A sample command.
 
162
            __doc__ = """A sample command.
156
163
 
157
164
            Blah blah blah.
158
165
 
199
206
    def test_help_custom_section_ordering(self):
200
207
        """Custom descriptive sections should remain in the order given."""
201
208
        class cmd_Demo(commands.Command):
202
 
            """A sample command.
 
209
            __doc__ = """A sample command.
203
210
 
204
211
            Blah blah blah.
205
212
 
245
252
    def test_help_text_custom_usage(self):
246
253
        """Help text may contain a custom usage section."""
247
254
        class cmd_Demo(commands.Command):
248
 
            """A sample command.
 
255
            __doc__ = """A sample command.
249
256
 
250
257
            :Usage:
251
258
                cmd Demo [opts] args
274
281
            '  Blah blah blah.\n\n')
275
282
 
276
283
 
277
 
class TestRegisteredTopic(tests.TestCase):
 
284
class TestRegisteredTopic(TestHelp):
278
285
    """Tests for the RegisteredTopic class."""
279
286
 
280
287
    def test_contruct(self):
313
320
        self.assertEqual('baz', topic.get_help_topic())
314
321
 
315
322
 
316
 
class TestTopicIndex(tests.TestCase):
 
323
class TestTopicIndex(TestHelp):
317
324
    """Tests for the HelpTopicIndex class."""
318
325
 
319
326
    def test_default_constructable(self):
346
353
        self.assertEqual('', index.prefix)
347
354
 
348
355
 
349
 
class TestCommandIndex(tests.TestCase):
 
356
class TestCommandIndex(TestHelp):
350
357
    """Tests for the HelpCommandIndex class."""
351
358
 
352
359
    def test_default_constructable(self):