Exemplo n.º 1
0
def test_regression_dataclasses_inference(HANDLER):
    project_path = Path("regrtest_data") / "dataclasses_pyreverse"
    path = get_project(str(project_path))

    cdg = ClassDiadefGenerator(Linker(path), HANDLER)
    special = "regrtest_data.dataclasses_pyreverse.InventoryItem"
    cd = cdg.class_diagram(path, special)
    assert cd.title == special
 def test_known_values2(self, 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")]
Exemplo n.º 3
0
 def test_known_values2(self, 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')]
Exemplo n.º 4
0
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")]
Exemplo n.º 5
0
 def test_functional_relation_extraction(self):
     """functional test of relations extraction;
     different classes possibly in different modules"""
     # XXX should be catching pyreverse environnement problem but doesn't
     # pyreverse doesn't extracts the relations but this test ok
     project = get_project('data')
     handler = DiadefsHandler(Config())
     diadefs = handler.get_diadefs(project, Linker(project, tag=True) )
     cd = diadefs[1]
     relations = _process_relations(cd.relationships)
     self.assertEqual(relations, self._should_rels)
Exemplo n.º 6
0
 def test_functional_relation_extraction(self):
     """functional test of relations extraction;
     different classes possibly in different modules"""
     # XXX should be catching pyreverse environnement problem but doesn't
     # pyreverse doesn't extracts the relations but this test ok
     project = get_project('data')
     handler = DiadefsHandler(Config())
     diadefs = handler.get_diadefs(project, Linker(project, tag=True))
     cd = diadefs[1]
     relations = _process_relations(cd.relationships)
     self.assertEqual(relations, self._should_rels)
Exemplo n.º 7
0
 def test_known_values2(self):
     project = get_project('data.clientmodule_test')
     dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project)
     self.assertEqual(len(dd), 1)
     keys = [d.TYPE for d in dd]
     self.assertEqual(keys, ['class'])
     cd = dd[0]
     self.assertEqual(cd.title, 'classes No Name')
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [(True, 'Ancestor'), (True, 'DoNothing'),
                                (True, 'Specialization')])
Exemplo n.º 8
0
 def test_known_values2(self):
     project = get_project('data.clientmodule_test')
     dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project)
     self.assertEqual(len(dd), 1)
     keys = [d.TYPE for d in dd]
     self.assertEqual(keys, ['class'])
     cd = dd[0]
     self.assertEqual(cd.title, 'classes No Name')
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [(True, 'Ancestor'),
                                (True, 'DoNothing'),
                                (True, 'Specialization')]
                       )
Exemplo n.º 9
0
"""
unittest for the extensions.diadefslib modules
"""

import unittest
import sys

import astroid
from astroid import MANAGER
from astroid.inspector import Linker

from pylint.pyreverse.diadefslib import *

from unittest_pyreverse_writer import Config, get_project

PROJECT = get_project('data')
HANDLER = DiadefsHandler(Config())


def _process_classes(classes):
    """extract class names of a list"""
    return sorted([(isinstance(c.node, astroid.Class), c.title)
                   for c in classes])


def _process_relations(relations):
    """extract relation indices from a relation list"""
    result = []
    for rel_type, rels in relations.iteritems():
        for rel in rels:
            result.append(
Exemplo n.º 10
0
 def setUp(self):
     super(LinkerTest, self).setUp()
     self.project = get_project("data", "data")
     self.linker = inspector.Linker(self.project)
     self.linker.visit(self.project)
Exemplo n.º 11
0
"""

import unittest
import sys

import six

import astroid
from astroid import MANAGER

from pylint.pyreverse.inspector import Linker
from pylint.pyreverse.diadefslib import *

from unittest_pyreverse_writer import Config, get_project

PROJECT = get_project('data')
HANDLER = DiadefsHandler(Config())

def _process_classes(classes):
    """extract class names of a list"""
    return sorted([(isinstance(c.node, astroid.ClassDef), c.title) for c in classes])

def _process_relations(relations):
    """extract relation indices from a relation list"""
    result = []
    for rel_type, rels in six.iteritems(relations):
        for rel in rels:
            result.append( (rel_type, rel.from_object.title,
                            rel.to_object.title) )
    result.sort()
    return result
Exemplo n.º 12
0
def project():
    project = get_project("data", "data")
    linker = inspector.Linker(project)
    linker.visit(project)
    return project
def project():
    project = get_project('data', 'data')
    linker = inspector.Linker(project)
    linker.visit(project)
    return project
def PROJECT():
    return get_project("data")
Exemplo n.º 15
0
def PROJECT():
    return get_project('data')
Exemplo n.º 16
0
 def setUp(self):
     super(LinkerTest, self).setUp()
     self.project = get_project('data', 'data')
     self.linker = inspector.Linker(self.project)
     self.linker.visit(self.project)
def project():
    project = get_project("data", "data")
    linker = inspector.Linker(project)
    linker.visit(project)
    return project
Exemplo n.º 18
0
def PROJECT():
    return get_project("data")
def project():
    project = get_project('data', 'data')
    linker = inspector.Linker(project)
    linker.visit(project)
    return project