~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commands.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
    @staticmethod
66
66
    def get_command(options):
67
67
        class cmd_foo(commands.Command):
68
 
            __doc__ = 'Bar'
 
68
            'Bar'
69
69
 
70
70
            takes_options = options
71
71
 
120
120
class TestSeeAlso(tests.TestCase):
121
121
    """Tests for the see also functional of Command."""
122
122
 
123
 
    @staticmethod
124
 
    def _get_command_with_see_also(see_also):
125
 
        class ACommand(commands.Command):
126
 
            __doc__ = """A sample command."""
127
 
            _see_also = see_also
128
 
        return ACommand()
129
 
 
130
123
    def test_default_subclass_no_see_also(self):
131
 
        command = self._get_command_with_see_also([])
 
124
        class ACommand(commands.Command):
 
125
            """A sample command."""
 
126
        command = ACommand()
132
127
        self.assertEqual([], command.get_see_also())
133
128
 
134
129
    def test__see_also(self):
135
130
        """When _see_also is defined, it sets the result of get_see_also()."""
136
 
        command = self._get_command_with_see_also(['bar', 'foo'])
 
131
        class ACommand(commands.Command):
 
132
            _see_also = ['bar', 'foo']
 
133
        command = ACommand()
137
134
        self.assertEqual(['bar', 'foo'], command.get_see_also())
138
135
 
139
136
    def test_deduplication(self):
140
137
        """Duplicates in _see_also are stripped out."""
141
 
        command = self._get_command_with_see_also(['foo', 'foo'])
 
138
        class ACommand(commands.Command):
 
139
            _see_also = ['foo', 'foo']
 
140
        command = ACommand()
142
141
        self.assertEqual(['foo'], command.get_see_also())
143
142
 
144
143
    def test_sorted(self):
145
144
        """_see_also is sorted by get_see_also."""
146
 
        command = self._get_command_with_see_also(['foo', 'bar'])
 
145
        class ACommand(commands.Command):
 
146
            _see_also = ['foo', 'bar']
 
147
        command = ACommand()
147
148
        self.assertEqual(['bar', 'foo'], command.get_see_also())
148
149
 
149
150
    def test_additional_terms(self):
150
151
        """Additional terms can be supplied and are deduped and sorted."""
151
 
        command = self._get_command_with_see_also(['foo', 'bar'])
 
152
        class ACommand(commands.Command):
 
153
            _see_also = ['foo', 'bar']
 
154
        command = ACommand()
152
155
        self.assertEqual(['bar', 'foo', 'gam'],
153
156
            command.get_see_also(['gam', 'bar', 'gam']))
154
157
 
209
212
            "extend_command", hook_calls.append, None)
210
213
        # create a command, should not fire
211
214
        class cmd_test_extend_command_hook(commands.Command):
212
 
            __doc__ = """A sample command."""
 
215
            """A sample command."""
213
216
        self.assertEqual([], hook_calls)
214
217
        # -- as a builtin
215
218
        # register the command class, should not fire
246
249
        commands.install_bzr_command_hooks()
247
250
        hook_calls = []
248
251
        class ACommand(commands.Command):
249
 
            __doc__ = """A sample command."""
 
252
            """A sample command."""
250
253
        def get_cmd(cmd_or_None, cmd_name):
251
254
            hook_calls.append(('called', cmd_or_None, cmd_name))
252
255
            if cmd_name in ('foo', 'info'):
277
280
        """Hook get_missing_command for testing."""
278
281
        self.hook_calls = []
279
282
        class ACommand(commands.Command):
280
 
            __doc__ = """A sample command."""
 
283
            """A sample command."""
281
284
        def get_missing_cmd(cmd_name):
282
285
            self.hook_calls.append(('called', cmd_name))
283
286
            if cmd_name in ('foo', 'info'):