Exemple #1
0
 def test_del_single(self):
     stmt = 'del a'
     env = {'a': int}
     type_env = penty.type_exec(dedent(stmt), env)
     self.assertNotIn('a', type_env)
     with self.assertRaises(penty.penty.UnboundIdentifier):
         stmt = 'del a; a'
         penty.type_exec(dedent(stmt), env)
Exemple #2
0
 def test_del_multiple(self):
     stmt = 'del a, b'
     env = {'a': int, 'b': float}
     type_env = penty.type_exec(dedent(stmt), env)
     self.assertNotIn('a', type_env)
     self.assertNotIn('b', type_env)
     with self.assertRaises(penty.penty.UnboundIdentifier):
         stmt = 'del a, b; a, b'
         penty.type_exec(dedent(stmt), env)
Exemple #3
0
 def assertIsType(self, stmt, expr, ty, env={}):
     if not isinstance(ty, set):
         ty = {ty}
     type_env = penty.type_exec(dedent(stmt), {})
     type_env.update({k: v if isinstance(v, set) else {v}
                      for k, v in env.items()})
     self.assertEqual(penty.type_eval(expr, type_env), ty)
Exemple #4
0
 def assertIsType(self, expr, ty, env={}):
     env = penty.type_exec("import numpy as np", env.copy())
     super(TestNumpyBase, self).assertIsType(expr, ty, env)
Exemple #5
0
 def assertIsType(self, stmt, expr, ty, env={}):
     type_env = penty.type_exec(dedent(stmt), {})
     type_env.update(
         {k: v if isinstance(v, set) else {v}
          for k, v in env.items()})
     super(TestStmt, self).assertIsType(expr, ty, type_env)
Exemple #6
0
 def assertIsType(self, expr, ty, env={}):
     if not isinstance(ty, set):
         ty = {ty}
     env = {k: v if isinstance(v, set) else {v} for k, v in env.items()}
     env = penty.type_exec("import numpy as np", env)
     self.assertEqual(penty.type_eval(expr, env), ty)