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
评论列表
文章目录