~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commands.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) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from cStringIO import StringIO
17
18
import errno
18
 
import inspect
19
19
import sys
20
20
 
21
21
from bzrlib import (
33
33
 
34
34
class TestCommands(tests.TestCase):
35
35
 
36
 
    def test_all_commands_have_help(self):
37
 
        commands._register_builtin_commands()
38
 
        commands_without_help = set()
39
 
        base_doc = inspect.getdoc(commands.Command)
40
 
        for cmd_name in commands.all_command_names():
41
 
            cmd = commands.get_cmd_object(cmd_name)
42
 
            cmd_help = cmd.help()
43
 
            if not cmd_help or cmd_help == base_doc:
44
 
                commands_without_help.append(cmd_name)
45
 
        self.assertLength(0, commands_without_help)
46
 
 
47
36
    def test_display_command(self):
48
37
        """EPIPE message is selectively suppressed"""
49
38
        def pipe_thrower():
91
80
        self.assertContainsRe(c.get_help_text(), '--foo')
92
81
 
93
82
 
94
 
class TestInvokedAs(tests.TestCase):
95
 
 
96
 
    def test_invoked_as(self):
97
 
        """The command object knows the actual name used to invoke it."""
98
 
        commands.install_bzr_command_hooks()
99
 
        commands._register_builtin_commands()
100
 
        # get one from the real get_cmd_object.
101
 
        c = commands.get_cmd_object('ci')
102
 
        self.assertIsInstance(c, builtins.cmd_commit)
103
 
        self.assertEquals(c.invoked_as, 'ci')
104
 
 
105
 
 
106
83
class TestGetAlias(tests.TestCase):
107
84
 
108
85
    def _get_config(self, config_text):
109
 
        my_config = config.GlobalConfig.from_string(config_text)
 
86
        my_config = config.GlobalConfig()
 
87
        config_file = StringIO(config_text.encode('utf-8'))
 
88
        my_config._parser = my_config._get_parser(file=config_file)
110
89
        return my_config
111
90
 
112
91
    def test_simple(self):
354
333
        cmds = list(commands.all_command_names())
355
334
        self.assertEqual(['called'], hook_calls)
356
335
        self.assertSubset(['foo', 'bar'], cmds)
 
336
 
 
337
class TestDeprecations(tests.TestCase):
 
338
 
 
339
    def test_shlex_split_unicode_deprecation(self):
 
340
        res = self.applyDeprecated(
 
341
                symbol_versioning.deprecated_in((2, 2, 0)),
 
342
                commands.shlex_split_unicode, 'whatever')