def test_project_node(project: Project) -> None: expected = [ "data", "data.clientmodule_test", "data.property_pattern", "data.suppliermodule_test", ] assert sorted(project.keys()) == expected
def test_instance_attrs_resolution(project: Project) -> None: klass = project.get_module("data.clientmodule_test")["Specialization"] assert hasattr(klass, "instance_attrs_type") type_dict = klass.instance_attrs_type assert len(type_dict) == 3 keys = sorted(type_dict.keys()) assert keys == ["_id", "relation", "relation2"] assert isinstance(type_dict["relation"][0], astroid.bases.Instance), type_dict["relation"] assert type_dict["relation"][0].name == "DoNothing" assert type_dict["_id"][0] is astroid.Uninferable
def test_locals_assignment_resolution(project: Project) -> None: klass = project.get_module("data.clientmodule_test")["Specialization"] assert hasattr(klass, "locals_type") type_dict = klass.locals_type assert len(type_dict) == 2 keys = sorted(type_dict.keys()) assert keys == ["TYPE", "top"] assert len(type_dict["TYPE"]) == 1 assert type_dict["TYPE"][0].value == "final class" assert len(type_dict["top"]) == 1 assert type_dict["top"][0].value == "class"
def test_class_implements_specialization(project: Project) -> None: klass = project.get_module("data.clientmodule_test")["Specialization"] assert hasattr(klass, "implements") assert len(klass.implements) == 0
def test_class_implements(project: Project) -> None: klass = project.get_module("data.clientmodule_test")["Ancestor"] assert hasattr(klass, "implements") assert len(klass.implements) == 1 assert isinstance(klass.implements[0], nodes.ClassDef) assert klass.implements[0].name == "Interface"