示例#1
0
    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 == [])
示例#2
0
    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 == [])
示例#3
0
    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'])
示例#4
0
    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'])
示例#5
0
    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