Exemplo n.º 1
0
 def test_ignore_lambda(self):
     code = textwrap.dedent("""
         test = lambda x: x
     """)
     
     tree = ast.parse(code)
     checker = TypeChecker(tree, __file__)
     
     results = [err for err in checker.run()]
     self.assertEquals(results, [])
Exemplo n.º 2
0
 def test_types(self):
     code = textwrap.dedent("""
         @types(returns=str)
         def test():
             return 'Hello'
     """)
     
     tree = ast.parse(code)
     checker = TypeChecker(tree, __file__)
     
     results = [err for err in checker.run()]
     self.assertEquals(results, [])
Exemplo n.º 3
0
 def test_failure(self):
     code = textwrap.dedent("""
         def test():
             return 'Hello'
     """)
     
     tree = ast.parse(code)
     checker = TypeChecker(tree, __file__)
     
     bad_lineno = 2
     results = [err for err in checker.run()]
     self.assertEquals(results[0][0], bad_lineno)
Exemplo n.º 4
0
 def test_property(self):
     code = textwrap.dedent("""
         class TestClass(object):
             @types()
             def __init__(self):
                 self.__test = 5
             
             @property
             @types(returns=int)
             def test(self):
                 return self.__test
                 
             @test.setter
             @types(new_val=int)
             def test(self, new_val):
                 self.__test = new_val
     """)
     
     tree = ast.parse(code)
     checker = TypeChecker(tree, __file__)
     
     results = [err for err in checker.run()]
     self.assertEquals(results, [])