/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_commands.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import inspect
19
19
import sys
20
20
 
21
 
from bzrlib import (
 
21
from .. import (
22
22
    builtins,
23
23
    commands,
24
24
    config,
27
27
    tests,
28
28
    trace,
29
29
    )
30
 
from bzrlib.commands import display_command
31
 
from bzrlib.tests import TestSkipped
 
30
from ..commands import display_command
 
31
from . import TestSkipped
32
32
 
33
33
 
34
34
class TestCommands(tests.TestCase):
195
195
 
196
196
    def setUp(self):
197
197
        super(TestRegisterLazy, self).setUp()
198
 
        import bzrlib.tests.fake_command
199
 
        del sys.modules['bzrlib.tests.fake_command']
 
198
        import breezy.tests.fake_command
 
199
        del sys.modules['breezy.tests.fake_command']
200
200
        global lazy_command_imported
201
201
        lazy_command_imported = False
202
202
        commands.install_bzr_command_hooks()
206
206
        commands.plugin_cmds.remove('fake')
207
207
 
208
208
    def assertIsFakeCommand(self, cmd_obj):
209
 
        from bzrlib.tests.fake_command import cmd_fake
 
209
        from breezy.tests.fake_command import cmd_fake
210
210
        self.assertIsInstance(cmd_obj, cmd_fake)
211
211
 
212
212
    def test_register_lazy(self):
213
213
        """Ensure lazy registration works"""
214
214
        commands.plugin_cmds.register_lazy('cmd_fake', [],
215
 
                                           'bzrlib.tests.fake_command')
 
215
                                           'breezy.tests.fake_command')
216
216
        self.addCleanup(self.remove_fake)
217
217
        self.assertFalse(lazy_command_imported)
218
218
        fake_instance = commands.get_cmd_object('fake')
221
221
 
222
222
    def test_get_unrelated_does_not_import(self):
223
223
        commands.plugin_cmds.register_lazy('cmd_fake', [],
224
 
                                           'bzrlib.tests.fake_command')
 
224
                                           'breezy.tests.fake_command')
225
225
        self.addCleanup(self.remove_fake)
226
226
        commands.get_cmd_object('status')
227
227
        self.assertFalse(lazy_command_imported)
228
228
 
229
229
    def test_aliases(self):
230
230
        commands.plugin_cmds.register_lazy('cmd_fake', ['fake_alias'],
231
 
                                           'bzrlib.tests.fake_command')
 
231
                                           'breezy.tests.fake_command')
232
232
        self.addCleanup(self.remove_fake)
233
233
        fake_instance = commands.get_cmd_object('fake_alias')
234
234
        self.assertIsFakeCommand(fake_instance)
267
267
        try:
268
268
            # register the command class, should not fire
269
269
            commands.plugin_cmds.register_lazy('cmd_fake', [],
270
 
                                               'bzrlib.tests.fake_command')
 
270
                                               'breezy.tests.fake_command')
271
271
            self.assertEqual([], hook_calls)
272
272
            # and ask for the object, should fire
273
273
            cmd = commands.get_cmd_object('fake')
373
373
        self.assertSubset(['foo', 'bar'], cmds)
374
374
 
375
375
class TestPreAndPostCommandHooks(tests.TestCase):
376
 
    class TestError(StandardError):
 
376
    class TestError(Exception):
377
377
        __doc__ = """A test exception."""
378
378
 
379
379
    def test_pre_and_post_hooks(self):