def test_get_required_args2(self): def yeah(mandatory): """ :param mandatory: :return: """ return mandatory args, defaults = get_required_args(yeah) self.assertTrue(args == ['mandatory']) self.assertTrue(defaults == [])
def test_get_required_args3(self): def yeah(mandatory=0): """ :param mandatory: :return: """ return mandatory args, defaults = get_required_args(yeah) self.assertTrue(defaults == ['mandatory']) self.assertTrue(args == [])
def test_get_required_args(self): def yeah(mandatory, why=0, me=1): """ :param mandatory: :param why: :param me: :return: """ return mandatory + why + me args, defaults = get_required_args(yeah) self.assertTrue(args == ['mandatory']) self.assertTrue(defaults == ['why', 'me'])
def get_required_args_no_context(self): """ Get the arguments and default arguments of the job function. Any context parameter will be ignored. Returns args - the arguments of the job function. defaults - the default arguments of the job function. """ args, defaults = misc.get_required_args(self.__call__) try: args.remove('context') except KeyError: pass try: args.remove('self') except KeyError: pass return args, defaults