def __init__(self): if PY2: Command.__init__(self) Command.addCmdList(self, self.__cmdLists) else: super(FsCmd, self).__init__() super(FsCmd, self).addCmdList(self.__cmdLists)
def test_parse_separates_kwargs(self): command = Command(run=function) command.add_argument(Arg('keyword1', required=False, default=0)) args, kwargs = command.parse(['simple']) self.assertIn('keyword1', kwargs)
def test_parse_separates_args(self): command = Command(run=function) command.add_argument(Arg('simple', required=True)) args, kwargs = command.parse(['simple']) self.assertIn('simple', args)
def test_had_argument(self): command = Command(run=lambda new_argument: new_argument) self.assertEqual(len(command.args), 1) arg = Arg('new_argument', help='argument help') command.add_argument(arg) self.assertEqual(len(command.args), 1) self.assertEqual(command.args[0].help, 'argument help')
def test_merge_namespace(self): new_manager = Manager() new_manager.add_command(Command(name='new_command')) manager.merge(new_manager, namespace='new_namespace') self.assertIn('new_namespace.new_command', manager.commands)
def test_capture_all(self): command = Command(run=lambda argv: argv, capture_all=True) self.assertEqual(len(command.args), 0)
def test_add_argument_existsing(self): command = Command(run=lambda new_argument: new_argument) self.assertEqual(len(command.args), 1) arg = Arg('new_argument', help='argument help') self.assertRaises(Exception, command.add_argument, arg)