def test_function_without_parameters_no_return(self): def func(): return try: get_type_function(func) self.fail("The function parameters are mandatory") except PywyException as ex: self.assertTrue("the parameters for the Function are distinct than one," in str(ex))
def test_function_with_two_parameters_basic_return(self): def func(x: Mock, y: Mock) -> Mock: return Mock() try: get_type_function(func) self.fail("the function can have just one input") except PywyException as ex: self.assertTrue("the parameters for the Function are distinct than one" in str(ex))
def test_function_with_one_parameter_no_type_no_return(self): def func(x): return try: input_type, output_type = get_type_function(func) self.assertEqual(input_type, empty_type) self.assertEqual(output_type, empty_type) except PywyException as ex: self.fail(str(ex))
def test_function_with_one_parameter_with_obe_type_basic_return(self): def func(x: Mock) -> Mock: return Mock() try: input_type, output_type = get_type_function(func) self.assertEqual(input_type, Mock) self.assertEqual(output_type, Mock) except PywyException as ex: self.fail(str(ex))
def test_function_with_one_parameter_with_basic_type_basic_return(self): def func(x: int) -> int: return 0 try: input_type, output_type = get_type_function(func) self.assertEqual(input_type, int) self.assertEqual(output_type, int) except PywyException as ex: self.fail(str(ex))
def __init__(self, function: Function): types = get_type_function(function) if function else (None, None) super().__init__("Map", types[0], types[1]) self.function = function