Beispiel #1
0
 def test_help(self):
     registry = bzrdir.BzrDirFormatRegistry()
     registry.register_metadir('one', 'RepositoryFormat7', 'one help')
     registry.register_metadir(
         'two',
         'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
         'two help',
     )
     registry.register_metadir('hidden',
                               'RepositoryFormat7',
                               'hidden help',
                               hidden=True)
     registry.set_default('one')
     options = [
         option.RegistryOption('format',
                               'format help',
                               registry,
                               str,
                               value_switches=True,
                               title='Formats')
     ]
     parser = option.get_optparser(dict((o.name, o) for o in options))
     value = parser.format_option_help()
     self.assertContainsRe(value, 'format.*format help')
     self.assertContainsRe(value, 'one.*one help')
     self.assertContainsRe(value, 'Formats:\n *--format')
     self.assertNotContainsRe(value, 'hidden help')
 def test_verbose_quiet_linkage(self):
     parser = option.get_optparser(option.Option.STD_OPTIONS)
     self.check(parser, 0, [])
     self.check(parser, 1, ['-v'])
     self.check(parser, 2, ['-v', '-v'])
     self.check(parser, -1, ['-q'])
     self.check(parser, -2, ['-qq'])
     self.check(parser, -1, ['-v', '-v', '-q'])
     self.check(parser, 2, ['-q', '-v', '-v'])
     self.check(parser, 0, ['--no-verbose'])
     self.check(parser, 0, ['-v', '-q', '--no-quiet'])
Beispiel #3
0
 def test_verbose_quiet_linkage(self):
     parser = option.get_optparser(option.Option.STD_OPTIONS)
     self.check(parser, 0, [])
     self.check(parser, 1, ['-v'])
     self.check(parser, 2, ['-v', '-v'])
     self.check(parser, -1, ['-q'])
     self.check(parser, -2, ['-qq'])
     self.check(parser, -1, ['-v', '-v', '-q'])
     self.check(parser, 2, ['-q', '-v', '-v'])
     self.check(parser, 0, ['--no-verbose'])
     self.check(parser, 0, ['-v', '-q', '--no-quiet'])
Beispiel #4
0
 def option(self, opt):
     optswitches = {}
     parser = option.get_optparser({opt.name: opt})
     parser = self.wrap_parser(optswitches, parser)
     optswitches.clear()
     opt.add_option(parser, opt.short_name())
     if isinstance(opt, option.RegistryOption) and opt.enum_switch:
         enum_switch = '--%s' % opt.name
         enum_data = optswitches.get(enum_switch)
         if enum_data:
             try:
                 enum_data.registry_keys = opt.registry.keys()
             except ImportError, e:
                 enum_data.error_messages.append(
                     "ERROR getting registry keys for '--%s': %s"
                     % (opt.name, str(e).split('\n')[0]))
Beispiel #5
0
 def option(self, opt):
     optswitches = {}
     parser = option.get_optparser({opt.name: opt})
     parser = self.wrap_parser(optswitches, parser)
     optswitches.clear()
     opt.add_option(parser, opt.short_name())
     if isinstance(opt, option.RegistryOption) and opt.enum_switch:
         enum_switch = '--%s' % opt.name
         enum_data = optswitches.get(enum_switch)
         if enum_data:
             try:
                 enum_data.registry_keys = opt.registry.keys()
             except ImportError, e:
                 enum_data.error_messages.append(
                     "ERROR getting registry keys for '--%s': %s" %
                     (opt.name, str(e).split('\n')[0]))
Beispiel #6
0
 def test_help(self):
     registry = bzrdir.BzrDirFormatRegistry()
     registry.register_metadir('one', 'RepositoryFormat7', 'one help')
     registry.register_metadir('two',
         'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
         'two help',
         )
     registry.register_metadir('hidden', 'RepositoryFormat7', 'hidden help',
         hidden=True)
     registry.set_default('one')
     options = [option.RegistryOption('format', 'format help', registry,
                str, value_switches=True, title='Formats')]
     parser = option.get_optparser(dict((o.name, o) for o in options))
     value = parser.format_option_help()
     self.assertContainsRe(value, 'format.*format help')
     self.assertContainsRe(value, 'one.*one help')
     self.assertContainsRe(value, 'Formats:\n *--format')
     self.assertNotContainsRe(value, 'hidden help')
 def parse(self, options, args):
     parser = option.get_optparser(dict((o.name, o) for o in options))
     return parser.parse_args(args)
Beispiel #8
0
 def setUp(self):
     super(TestResolveActionOption, self).setUp()
     self.options = [conflicts.ResolveActionOption()]
     self.parser = option.get_optparser(
         dict((o.name, o) for o in self.options))
Beispiel #9
0
 def parse(self, options, args):
     parser = option.get_optparser(dict((o.name, o) for o in options))
     return parser.parse_args(args)
Beispiel #10
0
 def setUp(self):
     super(TestResolveActionOption, self).setUp()
     self.options = [conflicts.ResolveActionOption()]
     self.parser = option.get_optparser(dict((o.name, o)
                                             for o in self.options))