# Path: pythoscope/astbuilder.py
# def regenerate(tree):
#     """AST -> String
# 
#     Regenerate the source code from the AST tree.
#     """
#     if hasattr(tree, 'added_newline') and tree.added_newline:
#         return str(tree)[:-1]
#     else:
#         return str(tree)
# 
# Path: pythoscope/store.py
# def code_of(obj, reference=None):
#     """Return an AST for the given object.
# 
#     It is "code_of(obj)" instead of "obj.code" mostly for explicitness. Objects
#     have code attribute when they are created, but lose it once they are added
#     to a Module (see docstring for ObjectInModule). Existence of code_of
#     decouples a storage method (including caching) from an interface.
#     """
#     if reference is not None:
#         assert isinstance(obj, Module)
#     else:
#         reference = obj
#     return CodeTree.of(obj).get_code_of(reference)
# 
# Path: pythoscope/util.py
# def get_names(objects):
#     return map(lambda c: c.name, objects)


import sys
from nose import SkipTest
from pythoscope.inspector.static import inspect_code
from pythoscope.astbuilder import regenerate
from pythoscope.store import code_of
from pythoscope.util import get_names
from assertions import *
from helper import EmptyProject
    def test_correctly_inspects_bases_from_other_modules(self):
        module = self._inspect_code(class_inheriting_from_some_other_module_class)

        assert_length(module.objects, 1)
        assert_equal(["othermodule.Class"], module.objects[0].bases)

    def test_correctly_inspects_calculated_bases(self):
        class_with_namedtuple = "import collections\n\n" +\
        "class ClassWithNamedtuple(collections.namedtuple('Point', 'x y')):\n" +\
        "    pass\n"
        module = self._inspect_code(class_with_namedtuple)
        assert_single_class(module, "ClassWithNamedtuple")
        assert_equal(["collections.namedtuple('Point', 'x y')"], module.objects[0].bases)

    def test_ignores_existance_of_any_inner_class_methods(self):
        module = self._inspect_code(class_with_inner_class)

        assert_single_class(module, "OuterClass")
        assert_equal(["__init__", "outer_class_method"],
                     get_names(module.classes[0].methods))

    def test_inspects_test_modules(self):
        module = self._inspect_code(two_test_classes)

        assert_equal(["unittest"], module.imports)
        assert_equal(["FirstTestClass", "TestMore"],
                     get_names(module.test_classes))
        assert_equal(["test_this", "test_that"],
                     get_names(module.test_classes[0].test_cases))
        assert_equal(["test_more"],

# Path: pythoscope/astbuilder.py
# def regenerate(tree):
#     """AST -> String
# 
#     Regenerate the source code from the AST tree.
#     """
#     if hasattr(tree, 'added_newline') and tree.added_newline:
#         return str(tree)[:-1]
#     else:
#         return str(tree)
# 
# Path: pythoscope/store.py
# def code_of(obj, reference=None):
#     """Return an AST for the given object.
# 
#     It is "code_of(obj)" instead of "obj.code" mostly for explicitness. Objects
#     have code attribute when they are created, but lose it once they are added
#     to a Module (see docstring for ObjectInModule). Existence of code_of
#     decouples a storage method (including caching) from an interface.
#     """
#     if reference is not None:
#         assert isinstance(obj, Module)
#     else:
#         reference = obj
#     return CodeTree.of(obj).get_code_of(reference)
# 
# Path: pythoscope/util.py
# def get_names(objects):
#     return map(lambda c: c.name, objects)


# Path: test/test_static_inspector.py
import sys
from nose import SkipTest
from pythoscope.inspector.static import inspect_code
from pythoscope.astbuilder import regenerate
from pythoscope.store import code_of
from pythoscope.util import get_names
from assertions import *
from helper import EmptyProject

    def test_correctly_inspects_bases_from_other_modules(self):
        module = self._inspect_code(class_inheriting_from_some_other_module_class)

        assert_length(module.objects, 1)
        assert_equal(["othermodule.Class"], module.objects[0].bases)

    def test_correctly_inspects_calculated_bases(self):
        class_with_namedtuple = "import collections\n\n" +\
        "class ClassWithNamedtuple(collections.namedtuple('Point', 'x y')):\n" +\
        "    pass\n"
        module = self._inspect_code(class_with_namedtuple)
        assert_single_class(module, "ClassWithNamedtuple")
        assert_equal(["collections.namedtuple('Point', 'x y')"], module.objects[0].bases)

    def test_ignores_existance_of_any_inner_class_methods(self):
        module = self._inspect_code(class_with_inner_class)

        assert_single_class(module, "OuterClass")
        assert_equal(["__init__", "outer_class_method"],
                     get_names(module.classes[0].methods))

    def test_inspects_test_modules(self):
        module = self._inspect_code(two_test_classes)

        assert_equal(["unittest"], module.imports)
        assert_equal(["FirstTestClass", "TestMore"],
                     get_names(module.test_classes))
        assert_equal(["test_this", "test_that"],
                     get_names(module.test_classes[0].test_cases))
        assert_equal(["test_more"],

                     get_names(module.test_classes[1].test_cases))