/breezy/trunk

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

« back to all changes in this revision

Viewing changes to breezy/tests/test_commands.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
        self.assertIsInstance(hook_calls[0][1], builtins.cmd_info)
310
310
 
311
311
 
 
312
class TestCommandNotFound(tests.TestCase):
 
313
 
 
314
    def setUp(self):
 
315
        super(TestCommandNotFound, self).setUp()
 
316
        commands._register_builtin_commands()
 
317
        commands.install_bzr_command_hooks()
 
318
 
 
319
    def test_not_found_no_suggestion(self):
 
320
        e = self.assertRaises(errors.BzrCommandError,
 
321
            commands.get_cmd_object, 'idontexistand')
 
322
        self.assertEqual('unknown command "idontexistand"', str(e))
 
323
 
 
324
    def test_not_found_with_suggestion(self):
 
325
        e = self.assertRaises(errors.BzrCommandError,
 
326
            commands.get_cmd_object, 'statue')
 
327
        self.assertEqual('unknown command "statue". Perhaps you meant "status"',
 
328
            str(e))
 
329
 
 
330
 
312
331
class TestGetMissingCommandHook(tests.TestCase):
313
332
 
314
333
    def hook_missing(self):
429
448
        def pre_command(cmd):
430
449
            hook_calls.append('pre')
431
450
            # verify that all subclasses of BzrCommandError caught too
432
 
            raise errors.BzrOptionError()
 
451
            raise commands.BzrOptionError()
433
452
 
434
453
        def post_command(cmd, e):
435
454
            self.fail('post_command should not be called')
449
468
                          commands.run_bzr, [u'rocks'])
450
469
        self.assertEqual(['pre'], hook_calls)
451
470
 
 
471
 
 
472
class GuessCommandTests(tests.TestCase):
 
473
 
 
474
    def setUp(self):
 
475
        super(GuessCommandTests, self).setUp()
 
476
        commands._register_builtin_commands()
 
477
        commands.install_bzr_command_hooks()
 
478
 
 
479
    def test_guess_override(self):
 
480
        self.assertEqual('ci', commands.guess_command('ic'))
 
481
 
 
482
    def test_guess(self):
 
483
        commands.get_cmd_object('status')
 
484
        self.assertEqual('status', commands.guess_command('statue'))
 
485
 
 
486
    def test_none(self):
 
487
        self.assertIs(None, commands.guess_command('nothingisevenclose'))