~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

  • Committer: John Arbash Meinel
  • Date: 2011-07-18 14:22:20 UTC
  • mto: This revision was merged to the branch mainline in revision 6033.
  • Revision ID: john@arbash-meinel.com-20110718142220-nwylw659oip1ene9
Start at least testing the package_branch regex.
And start testing the is-up-to-date logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
22
22
    controldir,
23
23
    errors,
24
24
    option,
 
25
    registry,
25
26
    )
26
27
from bzrlib.builtins import cmd_commit
27
 
from bzrlib.commands import Command, parse_args
 
28
from bzrlib.commands import parse_args
28
29
from bzrlib.tests import TestCase
29
30
from bzrlib.repofmt import knitrepo
30
31
 
396
397
        self.assertTrue(format.is_hidden('hidden'))
397
398
        self.assertFalse(format.is_hidden('visible'))
398
399
 
 
400
    def test_short_name(self):
 
401
        registry = controldir.ControlDirFormatRegistry()
 
402
        opt = option.RegistryOption('format', help='', registry=registry)
 
403
        self.assertEquals(None, opt.short_name())
 
404
        opt = option.RegistryOption('format', short_name='F', help='',
 
405
            registry=registry)
 
406
        self.assertEquals('F', opt.short_name())
 
407
 
399
408
    def test_option_custom_help(self):
400
409
        the_opt = option.Option.OPTIONS['help']
401
410
        orig_help = the_opt.help[:]
404
413
        self.assertEqual('suggest lottery numbers', my_opt.help)
405
414
        self.assertEqual(orig_help, the_opt.help)
406
415
 
 
416
    def test_short_value_switches(self):
 
417
        reg = registry.Registry()
 
418
        reg.register('short', 'ShortChoice')
 
419
        reg.register('long', 'LongChoice')
 
420
        ropt = option.RegistryOption('choice', '', reg, value_switches=True,
 
421
            short_value_switches={'short': 's'})
 
422
        opts, args = parse([ropt], ['--short'])
 
423
        self.assertEqual('ShortChoice', opts.choice)
 
424
        opts, args = parse([ropt], ['-s'])
 
425
        self.assertEqual('ShortChoice', opts.choice)
 
426
 
407
427
 
408
428
class TestVerboseQuietLinkage(TestCase):
409
429