def test_functionnotdefined(self): try: raise FunctionNotDefined("foo", "foo in bar") except FunctionNotDefined as e: assert hasattr(e, 'func_name') assert getattr(e, 'func_name') == 'foo' assert hasattr(e, 'expression') assert getattr(e, 'expression') == 'foo in bar'
def _eval_call(self, node): if isinstance(node.func, ast.Attribute): func = self._eval(node.func) elif isinstance(node.func, ast.Num): func = lambda n: n * self._eval(node.func) else: try: func = self.functions[node.func.id] except KeyError: raise FunctionNotDefined(node.func.id, self.expr) return func(*(self._eval(a) for a in node.args), **dict(self._eval(k) for k in node.keywords))