test_ast.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:ouroboros 作者: pybee 项目源码 文件源码
def test_call(self):
        func = ast.Name("x", ast.Load())
        args = [ast.Name("y", ast.Load())]
        keywords = [ast.keyword("w", ast.Name("z", ast.Load()))]
        stararg = ast.Name("p", ast.Load())
        kwarg = ast.Name("q", ast.Load())
        call = ast.Call(ast.Name("x", ast.Store()), args, keywords, stararg,
                        kwarg)
        self.expr(call, "must have Load context")
        call = ast.Call(func, [None], keywords, stararg, kwarg)
        self.expr(call, "None disallowed")
        bad_keywords = [ast.keyword("w", ast.Name("z", ast.Store()))]
        call = ast.Call(func, args, bad_keywords, stararg, kwarg)
        self.expr(call, "must have Load context")
        call = ast.Call(func, args, keywords, ast.Name("z", ast.Store()), kwarg)
        self.expr(call, "must have Load context")
        call = ast.Call(func, args, keywords, stararg,
                        ast.Name("w", ast.Store()))
        self.expr(call, "must have Load context")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号