~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
        self.assertEqual('hello', name)
319
319
        self.assertEqual([], value)
320
320
 
 
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
 
321
328
 
322
329
class TestOptionDefinitions(TestCase):
323
330
    """Tests for options in the Bazaar codebase."""
324
331
 
325
332
    def get_builtin_command_options(self):
326
333
        g = []
327
 
        for cmd_name, cmd_class in sorted(commands.get_all_cmds()):
328
 
            cmd = cmd_class()
 
334
        for cmd_name in sorted(commands.all_command_names()):
 
335
            cmd = commands.get_cmd_object(cmd_name)
329
336
            for opt_name, opt in sorted(cmd.options().items()):
330
337
                g.append((cmd_name, opt))
331
338
        return g
338
345
        g = dict(option.Option.OPTIONS.items())
339
346
        used_globals = {}
340
347
        msgs = []
341
 
        for cmd_name, cmd_class in sorted(commands.get_all_cmds()):
342
 
            for option_or_name in sorted(cmd_class.takes_options):
 
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):
343
351
                if not isinstance(option_or_name, basestring):
344
352
                    self.assertIsInstance(option_or_name, option.Option)
345
353
                elif not option_or_name in g:
346
354
                    msgs.append("apparent reference to undefined "
347
355
                        "global option %r from %r"
348
 
                        % (option_or_name, cmd_class))
 
356
                        % (option_or_name, cmd))
349
357
                else:
350
358
                    used_globals.setdefault(option_or_name, []).append(cmd_name)
351
359
        unused_globals = set(g.keys()) - set(used_globals.keys())