def test_handle_calls_handle_label(self): namespace = argparse.Namespace(labels=['foo', 'bar']) command = LabelCommand() command.handle_label = mock.Mock() command.handle(namespace) self.assertEqual(command.handle_label.call_args_list, [ arg('foo', namespace), arg('bar', namespace), ])
class Command(BaseCommand): args = [ arg('-f', '--force', action='store_true', default=False), ] name = 'add' def handle(self, namespace): raise CommandError('foo bar baz', 92)
class AddCommand(BaseCommand): args = BaseCommand.args + [ arg('-f', '--force', action='store_true', default=False), ]
def test_kargs(self): self.assertEqual(arg(1, 2, 'foo', bar='baz').kwargs, {'bar': 'baz'})
def test_args(self): self.assertEqual(arg(1, 2, 'foo', bar='baz').args, (1, 2, 'foo'))
def test_get_label_arg(self): Command = type('Command', (SingleLabelCommand,), {}) label_arg = Command().get_label_arg() self.assertEqual(label_arg, arg('label', default=Command.label_default_value, nargs='?'))
def test_get_label_arg(self): Command = type('Command', (SingleLabelCommand, ), {}) label_arg = Command().get_label_arg() self.assertEqual( label_arg, arg('label', default=Command.label_default_value, nargs='?'))
class Command(BaseCommand): args = [ arg('-f', '--force', action='store_true', default=False), ] name = 'add' handle = mock.Mock()