コード例 #1
0
ファイル: hook.py プロジェクト: waytai/attest
 def visit_Assert(self, node):
     args = [
         _build(ast.Str, s=to_source(node.test)),
         node.msg if node.msg is not None else _build(ast.Str, s=''),
         _build(ast.Call,
                func=_build(ast.Name, id='globals', ctx=ast.Load()),
                args=[],
                keywords=[],
                starargs=None,
                kwargs=None),
         _build(ast.Call,
                func=_build(ast.Name, id='locals', ctx=ast.Load()),
                args=[],
                keywords=[],
                starargs=None,
                kwargs=None)
     ]
     return ast.copy_location(
         _build(ast.Expr,
                value=_build(ast.Call,
                             func=_build(ast.Name,
                                         id='assert_hook',
                                         ctx=ast.Load()),
                             args=args,
                             keywords=[],
                             starargs=None,
                             kwargs=None)), node)
コード例 #2
0
ファイル: hook.py プロジェクト: dahlia/attest
 def visit_Assert(self, node):
     args = [_build(ast.Str, s=to_source(node.test)),
             node.msg if node.msg is not None else _build(ast.Str, s=''),
             _build(ast.Call,
                 func=_build(ast.Name, id='globals', ctx=ast.Load()),
                 args=[], keywords=[], starargs=None, kwargs=None),
             _build(ast.Call,
                 func=_build(ast.Name, id='locals', ctx=ast.Load()),
                 args=[], keywords=[], starargs=None, kwargs=None)
            ]
     return ast.copy_location(
         _build(ast.Expr, value=_build(ast.Call,
                func=_build(ast.Name, id='assert_hook', ctx=ast.Load()),
                args=args, keywords=[], starargs=None, kwargs=None)), node)
コード例 #3
0
ファイル: hook.py プロジェクト: dahlia/attest
 def eval(self, node):
     return eval(to_source(node), self.globals, self.locals)
コード例 #4
0
ファイル: hook.py プロジェクト: dahlia/attest
 def code(self):
     """The :attr:`node` compiled into a code object."""
     if COMPILES_AST:
         return compile(self.node, self.filename, 'exec')
     return compile(to_source(self.node), self.filename, 'exec')
コード例 #5
0
ファイル: hook.py プロジェクト: waytai/attest
 def eval(self, node):
     return eval(to_source(node), self.globals, self.locals)
コード例 #6
0
ファイル: hook.py プロジェクト: waytai/attest
 def code(self):
     """The :attr:`node` compiled into a code object."""
     if COMPILES_AST:
         return compile(self.node, self.filename, 'exec')
     return compile(to_source(self.node), self.filename, 'exec')