def test_exctract_relations(self, HANDLER: DiadefsHandler, PROJECT: Project) -> None: """Test extract_relations between classes.""" cd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)[1] cd.extract_relationships() relations = _process_relations(cd.relationships) assert relations == self._should_rels
def test_property_handling(default_config: PyreverseConfig, get_project: Callable) -> None: project = get_project("data.property_pattern") class_diagram = DefaultDiadefGenerator( Linker(project), DiadefsHandler(default_config)).visit(project)[0] obj = class_diagram.classe("PropertyPatterns") assert len(class_diagram.get_methods(obj.node)) == 0 assert class_diagram.get_attrs(obj.node) == ["prop1", "prop2"]
def test_known_values1(HANDLER: DiadefsHandler, PROJECT: Project) -> None: dd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT) assert len(dd) == 2 keys = [d.TYPE for d in dd] assert keys == ["package", "class"] pd = dd[0] assert pd.title == "packages No Name" modules = sorted( (isinstance(m.node, nodes.Module), m.title) for m in pd.objects) assert modules == [ (True, "data"), (True, "data.clientmodule_test"), (True, "data.property_pattern"), (True, "data.suppliermodule_test"), ] cd = dd[1] assert cd.title == "classes No Name" classes = _process_classes(cd.objects) assert classes == [ (True, "Ancestor"), (True, "CustomException"), (True, "DoNothing"), (True, "DoNothing2"), (True, "DoSomething"), (True, "Interface"), (True, "PropertyPatterns"), (True, "Specialization"), ]
def setUpClass(cls): project = get_project(cls.datadir) linker = Linker(project) handler = DiadefsHandler(CONFIG) dd = DefaultDiadefGenerator(linker, handler).visit(project) for diagram in dd: diagram.extract_relationships() writer = DotWriter(CONFIG) writer.write(dd)
def setUpClass(cls): project = get_project(os.path.join(os.path.dirname(__file__), 'data')) linker = Linker(project) handler = DiadefsHandler(CONFIG) dd = DefaultDiadefGenerator(linker, handler).visit(project) for diagram in dd: diagram.extract_relationships() writer = DotWriter(CONFIG) writer.write(dd)
def test_known_values2(HANDLER): project = get_project("data.clientmodule_test") dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project) assert len(dd) == 1 keys = [d.TYPE for d in dd] assert keys == ["class"] cd = dd[0] assert cd.title == "classes No Name" classes = _process_classes(cd.objects) assert classes == [(True, "Ancestor"), (True, "Specialization")]
def setUpClass(cls): project = get_project(os.path.join(os.path.dirname(__file__), 'data')) linker = Linker(project) handler = DiadefsHandler(CONFIG) cls.dd = DefaultDiadefGenerator(linker, handler).visit(project) for diagram in cls.dd: diagram.extract_relationships() cls.writer = DotWriter(STDOUT_CONFIG) cls.package_diagram = cls.dd[0] cls.class_diagram = cls.dd[1]
def _setup(project: Project, config: PyreverseConfig, writer: DiagramWriter) -> Iterator: linker = Linker(project) handler = DiadefsHandler(config) dd = DefaultDiadefGenerator(linker, handler).visit(project) for diagram in dd: diagram.extract_relationships() writer.write(dd) yield for fname in (DOT_FILES + COLORIZED_DOT_FILES + VCG_FILES + PUML_FILES + COLORIZED_PUML_FILES + MMD_FILES + HTML_FILES): try: os.remove(fname) except FileNotFoundError: continue
def setup(): project = get_project(os.path.join(os.path.dirname(__file__), "data")) linker = Linker(project) CONFIG = Config() handler = DiadefsHandler(CONFIG) dd = DefaultDiadefGenerator(linker, handler).visit(project) for diagram in dd: diagram.extract_relationships() writer = DotWriter(CONFIG) writer.write(dd) yield for fname in DOT_FILES: try: os.remove(fname) except: continue
def test_known_values1(HANDLER, PROJECT): dd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT) assert len(dd) == 2 keys = [d.TYPE for d in dd] assert keys == ["package", "class"] pd = dd[0] assert pd.title == "packages No Name" modules = sorted([(isinstance(m.node, astroid.Module), m.title) for m in pd.objects]) assert modules == [ (True, "data"), (True, "data.clientmodule_test"), (True, "data.suppliermodule_test"), ] cd = dd[1] assert cd.title == "classes No Name" classes = _process_classes(cd.objects) assert classes == [ (True, "Ancestor"), (True, "DoNothing"), (True, "Interface"), (True, "Specialization"), ]
from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler from pylint.pyreverse.diagrams import set_counter from pylint.pyreverse.writer import DotWriter from pylint.pyreverse.utils import get_visibility from utils import FileTC, build_file_case, get_project, Config project = get_project('data') linker = Linker(project) set_counter(0) config = Config() handler = DiadefsHandler(config) dd = DefaultDiadefGenerator(linker, handler).visit(project) for diagram in dd: diagram.extract_relationships() class DotWriterTC(FileTC): generated_files = ( 'packages_No_Name.dot', 'classes_No_Name.dot', ) def setUp(self): FileTC.setUp(self) writer = DotWriter(config) writer.write(dd)
def test_exctract_relations(self, HANDLER, PROJECT): """test extract_relations between classes""" cd = DefaultDiadefGenerator(Linker(PROJECT), HANDLER).visit(PROJECT)[1] cd.extract_relationships() relations = _process_relations(cd.relationships) assert relations == self._should_rels