~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

  • Committer: Aaron Bentley
  • Date: 2009-03-24 15:47:32 UTC
  • mto: This revision was merged to the branch mainline in revision 4241.
  • Revision ID: aaron@aaronbentley.com-20090324154732-bwkvi4dx3o90a7dq
Add output, emit minimal inventory delta.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
        self.assertRaises(errors.BzrCommandError, self.parse, options,
103
103
                          ['--no-number'])
104
104
 
105
 
    def test_is_hidden(self):
106
 
        self.assertTrue(option.Option('foo', hidden=True).is_hidden('foo'))
107
 
        self.assertFalse(option.Option('foo', hidden=False).is_hidden('foo'))
108
 
 
109
105
    def test_registry_conversion(self):
110
106
        registry = bzrdir.BzrDirFormatRegistry()
111
107
        registry.register_metadir('one', 'RepositoryFormat7', 'one help')
318
314
        self.assertEqual('hello', name)
319
315
        self.assertEqual([], value)
320
316
 
321
 
    def test_list_option_param_name(self):
322
 
        """Test list options can have their param_name set."""
323
 
        options = [option.ListOption('hello', type=str, param_name='greeting')]
324
 
        opts, args = self.parse(
325
 
            options, ['--hello=world', '--hello=sailor'])
326
 
        self.assertEqual(['world', 'sailor'], opts.greeting)
327
 
 
328
317
 
329
318
class TestOptionDefinitions(TestCase):
330
319
    """Tests for options in the Bazaar codebase."""
331
320
 
332
321
    def get_builtin_command_options(self):
333
322
        g = []
334
 
        for cmd_name in sorted(commands.all_command_names()):
335
 
            cmd = commands.get_cmd_object(cmd_name)
 
323
        for cmd_name, cmd_class in sorted(commands.get_all_cmds()):
 
324
            cmd = cmd_class()
336
325
            for opt_name, opt in sorted(cmd.options().items()):
337
326
                g.append((cmd_name, opt))
338
327
        return g
345
334
        g = dict(option.Option.OPTIONS.items())
346
335
        used_globals = {}
347
336
        msgs = []
348
 
        for cmd_name in sorted(commands.all_command_names()):
349
 
            cmd = commands.get_cmd_object(cmd_name)
350
 
            for option_or_name in sorted(cmd.takes_options):
 
337
        for cmd_name, cmd_class in sorted(commands.get_all_cmds()):
 
338
            for option_or_name in sorted(cmd_class.takes_options):
351
339
                if not isinstance(option_or_name, basestring):
352
340
                    self.assertIsInstance(option_or_name, option.Option)
353
341
                elif not option_or_name in g:
354
342
                    msgs.append("apparent reference to undefined "
355
343
                        "global option %r from %r"
356
 
                        % (option_or_name, cmd))
 
344
                        % (option_or_name, cmd_class))
357
345
                else:
358
346
                    used_globals.setdefault(option_or_name, []).append(cmd_name)
359
347
        unused_globals = set(g.keys()) - set(used_globals.keys())