def test_check_args_2(self): def test_func(a: int, b: str, c=5, e=3, d=1): pass parser = Parser(test_func) self.my_assert(parser.check_args(*[1, '2'], **{'e': 8}), True)
def test_required_args_3(self): def test_func(a, b, c, d, e, *args, **kwargs): pass parser = Parser(test_func) self.my_assert(tuple(parser.required_args()), ('a', 'b', 'c', 'd', 'e'))
def test_get_arguments_4(self): def test_func(a, b, c=4, *args, d, e, **kwargs): pass parser = Parser(test_func) self.my_assert(tuple(parser.get_arguments()), (('a', 'b', 'c'), ('d', 'e'), ('args', ), ('kwargs', )))
def test_check_return_5(self): def test_func() -> tuple: pass parser = Parser(test_func) parser.check_return(tuple([1, 2, 3]))
def test_get_arguments_2(self): def test_func(a, b, c, d, *args): pass parser = Parser(test_func) self.my_assert(tuple(parser.get_arguments()), (('a', 'b', 'c', 'd'), (), ('args', ), ()))
def test_check_return_3(self): def test_func() -> int: pass parser = Parser(test_func) with self.assertRaises(ReturnAnnotationTypeError): parser.check_return(None)
def test_check_args_6(self): def test_func(a: int): pass parser = Parser(test_func) with self.assertRaises(AnnotationTypeError): parser.check_args('a')
def test_check_return_7(self): def test_func(): pass parser = Parser(test_func) parser.check_return(True) parser.check_return(False) parser.check_return(1) parser.check_return('1')
def test_check_return_4(self): def test_func() -> int: pass parser = Parser(test_func) parser.check_return(True) parser.check_return(False) parser.check_return(1)
def test_check_return_6(self): def test_func() -> (tuple, list): pass parser = Parser(test_func) parser.check_return(tuple([1, 2, 3])) parser.check_return([1, 2, 3])
def wrapper(*args, **kwargs): parser = Parser(f) parser.check_args(*args, **kwargs) result = f(*args, **kwargs) parser.check_return(result) return result
def test_check_args_1(self): def test_func(a: int, b: str, c: int = 5, d=1): pass parser = Parser(test_func) self.my_assert(parser.check_args(1, '2'), True)
def test_required_args_1(self): def test_func(a, b, c=5, d=1): pass parser = Parser(test_func) self.my_assert(tuple(parser.required_args()), ('a', 'b'))