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)
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)
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)
def assertIsType(self, expr, ty, env={}): env = penty.type_exec("import numpy as np", env.copy()) super(TestNumpyBase, self).assertIsType(expr, ty, env)
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)
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)