~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commands.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    commands,
22
22
    config,
23
23
    errors,
 
24
    tests,
24
25
    )
25
26
from bzrlib.commands import display_command
26
 
from bzrlib.tests import TestCase, TestSkipped
27
 
 
28
 
 
29
 
class TestCommands(TestCase):
 
27
from bzrlib.tests import TestSkipped
 
28
 
 
29
 
 
30
class TestCommands(tests.TestCase):
30
31
 
31
32
    def test_display_command(self):
32
33
        """EPIPE message is selectively suppressed"""
58
59
                          commands.run_bzr, ['log', u'--option\xb5'])
59
60
 
60
61
 
61
 
class TestGetAlias(TestCase):
 
62
class TestGetAlias(tests.TestCase):
62
63
 
63
64
    def _get_config(self, config_text):
64
65
        my_config = config.GlobalConfig()
93
94
            u"iam=whoami 'Erik B\u00e5gfors <erik@bagfors.nu>'\n")
94
95
        self.assertEqual([u'whoami', u'Erik B\u00e5gfors <erik@bagfors.nu>'],
95
96
                          commands.get_alias("iam", config=my_config))
 
97
 
 
98
 
 
99
class TestSeeAlso(tests.TestCase):
 
100
    """Tests for the see also functional of Command."""
 
101
 
 
102
    def test_default_subclass_no_see_also(self):
 
103
        class ACommand(commands.Command):
 
104
            """A sample command."""
 
105
        command = ACommand()
 
106
        self.assertEqual([], command.get_see_also())
 
107
 
 
108
    def test__see_also(self):
 
109
        """When _see_also is defined, it sets the result of get_see_also()."""
 
110
        class ACommand(commands.Command):
 
111
            _see_also = ['bar', 'foo']
 
112
        command = ACommand()
 
113
        self.assertEqual(['bar', 'foo'], command.get_see_also())
 
114
 
 
115
    def test_deduplication(self):
 
116
        """Duplicates in _see_also are stripped out."""
 
117
        class ACommand(commands.Command):
 
118
            _see_also = ['foo', 'foo']
 
119
        command = ACommand()
 
120
        self.assertEqual(['foo'], command.get_see_also())
 
121
 
 
122
    def test_sorted(self):
 
123
        """_see_also is sorted by get_see_also."""
 
124
        class ACommand(commands.Command):
 
125
            _see_also = ['foo', 'bar']
 
126
        command = ACommand()
 
127
        self.assertEqual(['bar', 'foo'], command.get_see_also())