~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commands.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-28 00:25:32 UTC
  • mfrom: (5264.1.2 command-help-bug-177500)
  • Revision ID: pqm@pqm.ubuntu.com-20100528002532-9bzj1fajyxckd1rg
(lifeless) Stop raising at runtime when a command has no help,
 instead have a test in the test suite that checks all known command objects.
 (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from cStringIO import StringIO
18
18
import errno
 
19
import inspect
19
20
import sys
20
21
 
21
22
from bzrlib import (
33
34
 
34
35
class TestCommands(tests.TestCase):
35
36
 
 
37
    def test_all_commands_have_help(self):
 
38
        commands._register_builtin_commands()
 
39
        commands_without_help = set()
 
40
        base_doc = inspect.getdoc(commands.Command)
 
41
        for cmd_name in commands.all_command_names():
 
42
            cmd = commands.get_cmd_object(cmd_name)
 
43
            cmd_help = cmd.help()
 
44
            if not cmd_help or cmd_help == base_doc:
 
45
                commands_without_help.append(cmd_name)
 
46
        self.assertLength(0, commands_without_help)
 
47
 
36
48
    def test_display_command(self):
37
49
        """EPIPE message is selectively suppressed"""
38
50
        def pipe_thrower():
79
91
        c = self.get_command([option.Option('foo', hidden=False)])
80
92
        self.assertContainsRe(c.get_help_text(), '--foo')
81
93
 
82
 
    def test_no_help_init_failure(self):
83
 
        class cmd_foo(commands.Command):
84
 
            pass
85
 
        self.assertRaises(ValueError, cmd_foo)
86
 
 
87
94
 
88
95
class TestGetAlias(tests.TestCase):
89
96