test_assignments.py 文件源码

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

项目:pyta 作者: pyta-uoft 项目源码 文件源码
def test_assign_complex_homogeneous(variables_dict):
    """test whether visitors properly set the type constraint of the a assign node representing a multi-target-assign
     with a homogeneous list as the value.
    """
    for variable_name in variables_dict:
        assume(not iskeyword(variable_name))
    program = ("x = ["
               + ", ".join([repr(value) for value in variables_dict.values()])
               + "]\n"
               + ", ".join(variables_dict.keys())
               + " = x")
    module, typeinferrer = cs._parse_text(program)
    ass_node = list(module.nodes_of_class(astroid.Assign))[0]
    for variable_name in variables_dict:
        var_tvar = module.type_environment.lookup_in_env(variable_name)
        assert typeinferrer.type_constraints.lookup_concrete(var_tvar) == ass_node.value.elts[0].type_constraints.type
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号