1. zjes
  2. rope_py3k

Commits

Ali Gholami Rudi  committed 246b5e9

Basic implicit interfaces
Reducing long automatic SOI analysis time

  • Participants
  • Parent commits 3971075
  • Branches trunk

Comments (0)

Files changed (24)

File docs/dev/done.txt

View file
  • Ignore whitespace
 ===========
 
 
+- Faster automatic SOI analysis : April 9, 2007
+
+
+- Basic implicit interfaces : April 9, 2007
+
+
 - Using a better object textual form : April 4, 2007
 
 

File docs/dev/issues.txt

View file
  • Ignore whitespace
 information and testing.
 
 
-Refactoring `Progress`
-======================
+Task `Progress`
+===============
 
 Currently refactorings cannot be stopped.  I propose to add an object
 for stopping and showing the progress of a time consuming task::
       def is_stopped(self):
           pass
 
+      def get_progress(self, total=None):
+          pass
+
+  class Progress(object):
+
+      def done(self, count):
+          pass
+
+      def set_task(self, name):
+          pass
+
 It requires adding an argument to all refactorings and other time
-consuming tasks and changing them to use this object.
+consuming tasks and changing them to use this object.  Alternatively
+we can change `TaskHandle` to have a method like `done(percent)`
+method that checks whether it is stopped and raises exceptions if it
+is.
 
 
 Better Concluded Data
 Python's Implicit Interfaces
 ============================
 
+Basic Implicit Interfaces
+-------------------------
+
+There are many dark points about these interfaces, but we should start
+from somewhere.
+
+
+Overview
+--------
+
 In python you don't have to define interfaces to declare that classes
 use a specific protocol or interface.  There are lots of such examples
 in standard library.

File docs/dev/stories.txt

View file
  • Ignore whitespace
 * Basic code formatting; correcting blank lines
 
 
-> Public Release 0.5m5 : April 15, 2007
+* Better warnings
+
+
+* Restructorings
+
+
+* Enhanced occurrence finding
 
 
 * Enhancing open project dialog
 
 
+> Public Release 0.5m5 : April 15, 2007
+
+
+* Stoppable refactorings
+
+
 * Inferring the object list comprehensions or generator expressions hold

File docs/dev/workingon.txt

View file
  • Ignore whitespace
-Possible Future Plans
-=====================
+Basic Implicit Interfaces
+=========================
 
-* List comprehension inference
-* Finding similar to extracted
-* Formatting
-* Modules without source
-* New function scopes
-* Better warnings
-* Lambdas as functions
-* Restructorings
-* Implicit interfaces
-* Stoppable refactorings
-* Enhanced occurrence finding
+- Breaking objectinfertest into two modules
+- Add `ImplicitInterfacesTest` to testsuite
+- Using SOI when `ObjectInfo.get_passed_objects()` return []
+- Rename `PyCore.call_info` to `PyCore.object_info`
+- Implicit interfaces and change method signature
+
+
+Reducing Long SOI Analysis Time
+===============================
+
+- Adding `History.get_prev_contents()`
+- Adding `TextChangeDetector` class::
+- Adding `TextChangeDetectorTest` to testsuite
+- Making `SOIVisitor` recursive
+- Passing `should_analyze` to `StaticOI.analyze_module()`
+- Long SOI Analysis time for large files
+
+* Better property handling; `Project.pycore`
+* ObjectDB after change method signature
 
 
 Remaining Small Stories

File rope/base/builtins.py

View file
  • Ignore whitespace
         scope, name = self._get_scope_and_pyname(pyname)
         if name is not None:
             pymodule = pyname.get_definition_location()[0]
-            return pymodule.pycore.call_info.get_per_name(scope, name)
+            return pymodule.pycore.object_info.get_per_name(scope, name)
         return None
 
     def save_per_name(self, value):
         scope, name = self._get_scope_and_pyname(pyname)
         if name is not None:
             pymodule = pyname.get_definition_location()[0]
-            pymodule.pycore.call_info.save_per_name(scope, name, value)
+            pymodule.pycore.object_info.save_per_name(scope, name, value)
 
 
 class _AttributeCollector(object):

File rope/base/change.py

View file
  • Ignore whitespace
                 string_date = 'today'
             elif date.date() == (datetime.date.today() - datetime.timedelta(1)):
                 string_date = 'yesterday'
-            elif date.month == datetime.date.today().month:
-                string_date = date.strftime('%a, %b %d')
             elif date.year == datetime.date.today().year:
                 string_date = date.strftime('%b %d')
             else:

File rope/base/codeanalyze.py

View file
  • Ignore whitespace
     This function is inefficient for multiple calls because of the
     recalculation of initialization data.
     """
+    return get_primary_and_pyname_at(pycore, resource, offset)[1]
+
+def get_primary_and_pyname_at(pycore, resource, offset):
+    """Finds the primary and pyname at offset
+
+    See notes about `get_pyname_at`.
+    """
     pymodule = pycore.resource_to_pyobject(resource)
     pyname_finder = rope.base.codeanalyze.ScopeNameFinder(pymodule)
-    pyname = pyname_finder.get_pyname_at(offset)
-    return pyname
+    return pyname_finder.get_primary_and_pyname_at(offset)
 
 def get_name_at(resource, offset):
     source_code = resource.read()

File rope/base/history.py

View file
  • Ignore whitespace
         self.undo_list.append(change)
         change.do()
 
+    def get_prev_contents(self, file):
+        result = self._search_for_change_contents(self.undo_list, file)
+        if result is not None:
+            return result
+        if file.exists() and not file.is_folder():
+            return file.read()
+        else:
+            return None
+
+    def _search_for_change_contents(self, change_list, file):
+        for change_ in reversed(change_list):
+            if isinstance(change_, change.ChangeSet):
+                result = self._search_for_change_contents(change_.changes,
+                                                          file)
+                if result is not None:
+                    return result
+            if isinstance(change_, change.ChangeContents) and \
+               change_.resource == file:
+                return change_.old_content
+
     def sync(self):
         if self.history_file is not None:
             output_file = file(self.history_file.real_path, 'w')

File rope/base/oi/objectinfer.py

View file
  • Ignore whitespace
 
     def __init__(self, pycore):
         self.soi = staticoi.StaticObjectInference(pycore)
-        self.call_info = pycore.call_info
+        self.object_info = pycore.object_info
 
     def infer_returned_object(self, pyobject, args):
         """Infer the `PyObject` this callable `PyObject` returns after calling"""
-        result = self.call_info.get_exact_returned(pyobject, args)
+        result = self.object_info.get_exact_returned(pyobject, args)
         if result is not None:
             return result
         result = self.soi.infer_returned_object(pyobject, args)
             if args and pyobject.get_module().get_resource() is not None:
                 params = args.get_arguments(
                     pyobject.get_param_names(special_args=False))
-                self.call_info.function_called(pyobject, params, result)
+                self.object_info.function_called(pyobject, params, result)
             return result
-        return self.call_info.get_returned(pyobject, args)
+        return self.object_info.get_returned(pyobject, args)
 
     def infer_parameter_objects(self, pyobject):
         """Infer the `PyObject`\s of parameters of this callable `PyObject`"""
-        result = self.call_info.get_parameter_objects(pyobject)
+        result = self.object_info.get_parameter_objects(pyobject)
         if result is None:
             result = self.soi.infer_parameter_objects(pyobject)
         return result
             if result is not None:
                 return result
 
+    def get_passed_objects(self, pyfunction, parameter_index):
+        result = self.object_info.get_passed_objects(pyfunction, parameter_index)
+        if not result:
+            statically_inferred = self.soi.infer_parameter_objects(pyfunction)
+            if len(statically_inferred) > parameter_index:
+                result.add(statically_inferred[parameter_index])
+        return result
+
     def _infer_assignment(self, assignment, pymodule):
         try:
             pyobject = self._infer_pyobject_for_assign_node(

File rope/base/oi/objectinfo.py

View file
  • Ignore whitespace
         self.project.add_observer(self.observer)
 
     def _resource_changed(self, resource):
-        self.objectdb.validate_file(resource.real_path)
+        try:
+            self.objectdb.validate_file(resource.real_path)
+        except SyntaxError:
+            pass
 
     def _resource_removed(self, resource, new_resource=None):
         self.observer.remove_resource(resource)
             return [self.to_pyobject.transform(parameter)
                     for parameter in parameters]
 
+    def get_passed_objects(self, pyfunction, parameter_index):
+        scope_info = self._find_scope_info(pyfunction)
+        result = set()
+        for call_info in scope_info.get_call_infos():
+            args = call_info.get_parameters()
+            if len(args) > parameter_index:
+                parameter = self.to_pyobject(args[parameter_index])
+                if parameter is not None:
+                    result.add(parameter)
+        return result
+
     def doi_data_received(self, data):
         def doi_to_normal(textual):
             pyobject = self.doi_to_pyobject.transform(textual)

File rope/base/oi/staticoi.py

View file
  • Ignore whitespace
 
     def infer_parameter_objects(self, pyobject):
         objects = []
-        if pyobject.parent is not None and isinstance(pyobject.parent, pyobjects.PyClass):
+        if pyobject.parent is not None and \
+           isinstance(pyobject.parent, pyobjects.PyClass):
             if not pyobject.decorators:
                 objects.append(pyobjects.PyObject(pyobject.parent))
             elif self._is_staticmethod_decorator(pyobject.decorators.nodes[0]):
     def _is_classmethod_decorator(self, node):
         return isinstance(node, compiler.ast.Name) and node.name == 'classmethod'
 
-    def analyze_module(self, pymodule):
+    def analyze_module(self, pymodule, should_analyze=None):
         """Analyze `pymodule` for static object inference"""
-        visitor = SOIVisitor(self.pycore, pymodule)
-        compiler.walk(pymodule.get_ast(), visitor)
+        _analyze_node(self.pycore, pymodule, should_analyze)
+
+
+def _analyze_node(pycore, pydefined, should_analyze):
+    if should_analyze is not None and not should_analyze(pydefined):
+        return
+    visitor = SOIVisitor(pycore, pydefined, should_analyze)
+    for child in pydefined.get_ast().getChildNodes():
+        compiler.walk(child, visitor)
 
 
 class SOIVisitor(object):
 
-    def __init__(self, pycore, pymodule):
+    def __init__(self, pycore, pydefined, should_analyze):
         self.pycore = pycore
-        self.pymodule = pymodule
-        self.scope = pymodule.get_scope()
+        self.pymodule = pydefined.get_module()
+        self.scope = pydefined.get_scope()
+        self.should_analyze = should_analyze
+
+    def visitFunction(self, node):
+        self._analyze_child(node)
+
+    def visitClass(self, node):
+        self._analyze_child(node)
+
+    def _analyze_child(self, node):
+        pydefined = self.scope.get_name(node.name).get_object()
+        _analyze_node(self.pycore, pydefined, self.should_analyze)
 
     def visitCallFunc(self, node):
         for child in node.getChildNodes():
             compiler.walk(child, self)
-        scope = self.scope.get_inner_scope_for_line(node.lineno)
-        primary, pyname = evaluate.get_primary_and_result(scope, node.node)
+        primary, pyname = evaluate.get_primary_and_result(self.scope, node.node)
         if pyname is None:
             return
         pyfunction = pyname.get_object()
            '__call__' in pyfunction.get_attributes():
             pyfunction = pyfunction.get_attribute('__call__')
         if isinstance(pyfunction, pyobjects.AbstractFunction):
-            args = evaluate.create_arguments(primary, pyfunction, node, scope)
+            args = evaluate.create_arguments(primary, pyfunction, node, self.scope)
         elif isinstance(pyfunction, pyobjects.PyClass):
             pyclass = pyfunction
             if '__init__' in pyfunction.get_attributes():
                 pyfunction = pyfunction.get_attribute('__init__').get_object()
             pyname = pynames.UnboundName(pyobjects.PyObject(pyclass))
-            args = evaluate.MixedArguments(pyname, node.args, scope)
+            args = evaluate.MixedArguments(pyname, node.args, self.scope)
         else:
             return
         self._call(pyfunction, args)
 
     def _call(self, pyfunction, args):
         if isinstance(pyfunction, pyobjects.PyFunction):
-            self.pycore.call_info.function_called(
+            self.pycore.object_info.function_called(
                 pyfunction, args.get_arguments(pyfunction.get_param_names()))
         # XXX: Maybe we should not call every builtin function
         if isinstance(pyfunction, builtins.BuiltinFunction):
             compiler.walk(child, visitor)
             nodes.extend(visitor.nodes)
         for assigned, levels in nodes:
-            scope = self.scope.get_inner_scope_for_line(node.lineno)
-            instance = evaluate.get_statement_result(scope, assigned.expr)
+            instance = evaluate.get_statement_result(self.scope, assigned.expr)
             args_pynames = []
             for ast in assigned.subs:
-                args_pynames.append(evaluate.get_statement_result(scope, ast))
+                args_pynames.append(evaluate.get_statement_result(self.scope, ast))
             value = self.pycore.object_infer._infer_assignment(
                 pynames._Assigned(node.expr, levels), self.pymodule)
             args_pynames.append(pynames.UnboundName(value))

File rope/base/project.py

View file
  • Ignore whitespace
         return self.ignored.is_ignored(resource)
 
     def close(self):
-        self.pycore.call_info.sync()
+        self.pycore.object_info.sync()
         self.history.sync()
 
     def set(self, key, value):

File rope/base/pycore.py

View file
  • Ignore whitespace
+import difflib
 import re
 import sys
 
             self._invalidate_resource_cache, self._invalidate_resource_cache)
         self.observer = rope.base.project.FilteredResourceObserver(observer)
         self.project.add_observer(self.observer)
-        self.call_info = rope.base.oi.objectinfo.ObjectInfoManager(project)
+        self.object_info = rope.base.oi.objectinfo.ObjectInfoManager(project)
         self.object_infer = rope.base.oi.objectinfer.ObjectInfer(self)
         if project.get_prefs().get('automatic_soi', False):
             self._init_automatic_soi()
     def _file_changed(self, resource, new_resource=None):
         if resource.exists() and self.is_python_file(resource):
             try:
-                self.analyze_module(resource)
+                old_contents = self.project.history.get_prev_contents(resource)
+                new_contents = resource.read()
+                # detecting changes in new_contents relative to old_contents
+                detector = TextChangeDetector(new_contents, old_contents)
+                def should_analyze(pydefined):
+                    scope = pydefined.get_scope()
+                    return detector.is_changed(scope.get_start(), scope.get_end())
+                self.analyze_module(resource, should_analyze)
             except SyntaxError:
                 pass
 
         controlling the process.
 
         """
-        receiver = self.call_info.doi_data_received
+        receiver = self.object_info.doi_data_received
         if not self.project.get_prefs().get('perform_doi', True):
             receiver = None
         runner = dynamicoi.PythonFileRunner(self, resource, args, stdin,
         runner.run()
         return runner
 
-    def analyze_module(self, resource):
+    def analyze_module(self, resource, should_analyze=None):
         """Analyze `resource` module for static object inference
 
         This function forces rope to analyze this module to concluded
         """
         pymodule = self.resource_to_pyobject(resource)
         pymodule._invalidate_concluded_data()
-        self.object_infer.soi.analyze_module(pymodule)
+        self.object_infer.soi.analyze_module(pymodule, should_analyze)
         pymodule._invalidate_concluded_data()
 
     def get_subclasses(self, pyclass):
             self.classes = classes
         return [class_ for class_ in self.classes
                 if pyclass in class_.get_superclasses()]
+
+
+class TextChangeDetector(object):
+
+    def __init__(self, old, new):
+        self.old = old
+        self.new = new
+        self._set_diffs()
+
+    def _set_diffs(self):
+        differ = difflib.Differ()
+        self.lines = []
+        for line in differ.compare(self.old.splitlines(True),
+                                   self.new.splitlines(True)):
+            if line.startswith(' '):
+                self.lines.append(False)
+            elif line.startswith('-'):
+                self.lines.append(True)
+
+    def is_changed(self, start, end):
+        """Tell whether any of start till end lines have changed
+
+        The end points are inclusive and indices start from 1.
+        """
+        for i in range(start - 1, min(end, len(self.lines))):
+            if self.lines[i]:
+                return True
+        return False

File rope/base/pynames.py

View file
  • Ignore whitespace
             result = rope.base.pyobjects.get_unknown()
         return result
 
+    def get_objects(self):
+        """Returns the list of objects passed as this parameter"""
+        object_infer = self.pyfunction.pycore._get_object_infer()
+        return object_infer.get_passed_objects(self.pyfunction, self.index)
+
     def get_definition_location(self):
         return (self.pyfunction.get_module(), self.pyfunction.get_ast().lineno)
 

File rope/refactor/change_signature.py

View file
  • Ignore whitespace
 
     def _set_name_and_pyname(self):
         self.name = codeanalyze.get_name_at(self.resource, self.offset)
-        self.pyname = codeanalyze.get_pyname_at(self.pycore, self.resource,
-                                                self.offset)
+        self.primary, self.pyname = codeanalyze.get_primary_and_pyname_at(
+            self.pycore, self.resource, self.offset)
         if self.pyname is None:
             return
         pyobject = self.pyname.get_object()
 
     def _change_calls(self, call_changer, in_hierarchy=False):
         changes = ChangeSet('Changing signature of <%s>' % self.name)
-        if in_hierarchy and self.is_method():
-            pyfunction = self.pyname.get_object()
-            pyclass = pyfunction.parent
-            pynames = rename.get_all_methods_in_hierarchy(pyclass, self.name)
-        else:
-            pynames = [self.pyname]
+        pynames = rename.FindMatchingPyNames(
+            self.primary, self.pyname, self.name, False,
+            in_hierarchy and self.is_method()).get_all()
         finder = occurrences.FilteredFinder(self.pycore, self.name, pynames)
         if self.others:
             name, pyname = self.others

File rope/refactor/rename.py

View file
  • Ignore whitespace
         self.resource = resource
         if offset is not None:
             self.old_name = codeanalyze.get_name_at(self.resource, offset)
-            self.old_pyname = codeanalyze.get_pyname_at(self.pycore,
-                                                        resource, offset)
+            self.old_instance, self.old_pyname = \
+                codeanalyze.get_primary_and_pyname_at(self.pycore,
+                                                      resource, offset)
             if self.old_pyname is None:
                 raise exceptions.RefactoringError(
                     'Rename refactoring should be performed on python identifiers.')
             if not resource.is_folder() and resource.name == '__init__.py':
                 resource = resource.parent
             dummy_pymodule = self.pycore.get_string_module('')
+            self.old_instance = None
             self.old_pyname = pynames.ImportedModule(dummy_pymodule,
                                                      resource=resource)
             if resource.is_folder():
         return False
 
     def _get_old_pynames(self, in_file, in_hierarchy):
-        if self.old_pyname is None:
-            return []
-        if self.is_method() and in_hierarchy:
-            return get_all_methods_in_hierarchy(self.old_pyname.get_object().
-                                                parent, self.old_name)
-        else:
-            return [self.old_pyname]
+        return FindMatchingPyNames(
+            self.old_instance, self.old_pyname, self.old_name,
+            in_file, in_hierarchy and self.is_method()).get_all()
 
     def _get_interesting_files(self, in_file):
         if not in_file:
     This class replaces the occurrences of a name.  Note that it only
     changes the scope containing the offset passed to the constructor.
     What's more it does not have any side-effects.  That is for
-    example changing occurrences of a module does not rename the 
+    example changing occurrences of a module does not rename the
     module; it merely replaces the occurrences of that module in a
     scope with the given expression.  This class is useful for
     performing many custom refactorings.
     return change_collector.get_changed()
 
 
-def get_all_methods_in_hierarchy(pyclass, attr_name):
-    superclasses = _get_superclasses_defining_method(pyclass, attr_name)
-    methods = set()
-    for superclass in superclasses:
-        methods.update(_get_all_methods_in_subclasses(
-                       superclass, attr_name))
-    return methods
+class FindMatchingPyNames(object):
+    """Find matching pynames
 
-def _get_superclasses_defining_method(pyclass, attr_name):
-    result = set()
-    for superclass in pyclass.get_superclasses():
-        if attr_name in superclass.get_attributes():
-            result.update(_get_superclasses_defining_method(
-                          superclass, attr_name))
-    if not result:
-        return set([pyclass])
-    return result
+    This is useful for finding overriding and overridden methods in
+    class hierarchy and attributes concluded from implicit interfaces.
+    """
 
-def _get_all_methods_in_subclasses(pyclass, attr_name):
-    result = set([pyclass.get_attribute(attr_name)])
-    for subclass in pyclass.pycore.get_subclasses(pyclass):
-        result.update(_get_all_methods_in_subclasses(subclass, attr_name))
-    return result
+    def __init__(self, primary, pyname, name, in_file, in_hierarchy):
+        self.name = name
+        self.pyname = pyname
+        self.instance = primary
+        self.in_file = in_file
+        self.in_hierarchy = in_hierarchy
+
+    def get_all(self):
+        result = set()
+        if self.pyname is not None:
+            result.add(self.pyname)
+        if isinstance(self.instance, pynames.ParameterName):
+            for pyobject in self.instance.get_objects():
+                try:
+                    result.add(pyobject.get_attribute(self.name))
+                except exceptions.AttributeNotFoundError:
+                    pass
+        if self.in_hierarchy:
+            for pyname in set(result):
+                result.update(self.get_all_methods_in_hierarchy(
+                              self.pyname.get_object().parent, self.name))
+        return list(result)
+
+
+    def get_all_methods_in_hierarchy(self, pyclass, attr_name):
+        superclasses = self._get_superclasses_defining_method(pyclass,
+                                                              attr_name)
+        methods = set()
+        for superclass in superclasses:
+            methods.update(self._get_all_methods_in_subclasses(
+                           superclass, attr_name))
+        return methods
+
+    def _get_superclasses_defining_method(self, pyclass, attr_name):
+        result = set()
+        for superclass in pyclass.get_superclasses():
+            if attr_name in superclass.get_attributes():
+                result.update(self._get_superclasses_defining_method(
+                              superclass, attr_name))
+        if not result:
+            return set([pyclass])
+        return result
+
+    def _get_all_methods_in_subclasses(self, pyclass, attr_name):
+        result = set([pyclass.get_attribute(attr_name)])
+        for subclass in pyclass.pycore.get_subclasses(pyclass):
+            result.update(self._get_all_methods_in_subclasses(subclass, attr_name))
+        return result

File ropetest/__init__.py

View file
  • Ignore whitespace
 import ropetest.pycoretest
 import ropetest.pyscopestest
 import ropetest.objectinfertest
+import ropetest.advanced_oi_test
 import ropetest.runmodtest
 import ropetest.builtintest
 import ropetest.historytest
     result.addTests(ropetest.pycoretest.suite())
     result.addTests(ropetest.pyscopestest.suite())
     result.addTests(ropetest.objectinfertest.suite())
+    result.addTests(ropetest.advanced_oi_test.suite())
     result.addTests(ropetest.runmodtest.suite())
     result.addTests(unittest.makeSuite(ropetest.builtintest.BuiltinTypesTest))
     result.addTests(ropetest.historytest.suite())

File ropetest/advanced_oi_test.py

View file
  • Ignore whitespace
+import unittest
+
+import rope.base.oi
+from ropetest import testutils
+
+
+class DynamicOITest(unittest.TestCase):
+
+    def setUp(self):
+        super(DynamicOITest, self).setUp()
+        self.project = testutils.sample_project(validate_objectdb=True)
+        self.pycore = self.project.get_pycore()
+
+    def tearDown(self):
+        testutils.remove_project(self.project)
+        super(DynamicOITest, self).tearDown()
+
+    def test_simple_dti(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func(a_func)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        self.assertEquals(pymod.get_attribute('a_func').get_object(),
+                          pymod.get_attribute('a_var').get_object())
+
+    def test_module_dti(self):
+        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        code = 'import mod1\ndef a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func(mod1)\n'
+        mod2.write(code)
+        self.pycore.run_module(mod2).wait_process()
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        self.assertEquals(self.pycore.resource_to_pyobject(mod1),
+                          pymod2.get_attribute('a_var').get_object())
+
+    def test_class_from_another_module_dti(self):
+        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        code1 = 'class AClass(object):\n    pass\n'
+        code2 = 'from mod1 import AClass\n' \
+               '\ndef a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func(AClass)\n'
+        mod1.write(code1)
+        mod2.write(code2)
+        self.pycore.run_module(mod2).wait_process()
+        pymod1 = self.pycore.resource_to_pyobject(mod1)
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        self.assertEquals(pymod2.get_attribute('AClass').get_object(),
+                          pymod2.get_attribute('a_var').get_object())
+
+
+    def test_class_dti(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class AClass(object):\n    pass\n' \
+               '\ndef a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func(AClass)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        self.assertEquals(pymod.get_attribute('AClass').get_object(),
+                          pymod.get_attribute('a_var').get_object())
+
+    def test_instance_dti(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class AClass(object):\n    pass\n' \
+               '\ndef a_func(arg):\n    return eval("arg()")\n' \
+               'a_var = a_func(AClass)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        self.assertEquals(pymod.get_attribute('AClass').get_object(),
+                          pymod.get_attribute('a_var').get_object().get_type())
+
+    def test_method_dti(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class AClass(object):\n    def a_method(self, arg):\n        return eval("arg()")\n' \
+               'an_instance = AClass()\n' \
+               'a_var = an_instance.a_method(AClass)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        self.assertEquals(pymod.get_attribute('AClass').get_object(),
+                          pymod.get_attribute('a_var').get_object().get_type())
+
+    def test_function_argument_dti(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg):\n    pass\n' \
+               'a_func(a_func)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
+        self.assertEquals(pyscope.get_name('a_func').get_object(),
+                          pyscope.get_scopes()[0].get_name('arg').get_object())
+
+    def test_classes_with_the_same_name(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg):\n    class AClass(object):\n        pass\n    return eval("arg")\n' \
+               'class AClass(object):\n    pass\n' \
+               'a_var = a_func(AClass)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        self.assertEquals(pymod.get_attribute('AClass').get_object(),
+                          pymod.get_attribute('a_var').get_object())
+
+    def test_nested_classes(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func():\n    class AClass(object):\n        pass\n    return AClass\n' \
+               'def another_func(arg):\n    return eval("arg")\n' \
+               'a_var = another_func(a_func())\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
+        self.assertEquals(pyscope.get_scopes()[0].get_name('AClass').get_object(),
+                          pyscope.get_name('a_var').get_object())
+
+    def test_function_argument_dti2(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg, a_builtin_type):\n    pass\n' \
+               'a_func(a_func, [])\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
+        self.assertEquals(pyscope.get_name('a_func').get_object(),
+                          pyscope.get_scopes()[0].get_name('arg').get_object())
+
+    def test_dti_and_concluded_data_invalidation(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func(a_func)\n'
+        mod.write(code)
+        pymod = self.pycore.resource_to_pyobject(mod)
+        pymod.get_attribute('a_var').get_object()
+        self.pycore.run_module(mod).wait_process()
+        self.assertEquals(pymod.get_attribute('a_func').get_object(),
+                          pymod.get_attribute('a_var').get_object())
+
+    def test_list_objects_and_dynamicoi(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func([C()])[0]\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_for_loops_and_dynamicoi(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
+               'for c in a_func([C()]):\n    a_var = c\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_dict_objects_and_dynamicoi(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C(object):\n    pass\n' \
+               'def a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func({1: C()})[1]\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_dict_keys_and_dynamicoi(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C(object):\n    pass\n' \
+               'def a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func({C(): 1}).keys()[0]\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_dict_keys_and_dynamicoi2(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(arg):\n    return eval("arg")\n' \
+               'a, b = a_func((C1(), C2()))\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_strs_and_dynamicoi(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func("hey")\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertTrue(isinstance(a_var.get_type(), rope.base.builtins.Str))
+
+    def test_textual_transformations(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C(object):\n    pass\ndef f():\n    pass\na_var = C()\n' \
+               'a_list = [C()]\na_str = "hey"\na_file = open("file.txt")\n'
+        mod.write(code)
+        to_pyobject = rope.base.oi.transform.TextualToPyObject(self.project)
+        to_textual = rope.base.oi.transform.PyObjectToTextual(self.project)
+        pymod = self.pycore.resource_to_pyobject(mod)
+        def complex_to_textual(pyobject):
+            return to_textual.transform(
+                to_pyobject.transform(to_textual.transform(pyobject)))
+        for name in ('C', 'f', 'a_var', 'a_list', 'a_str', 'a_file'):
+            var = pymod.get_attribute(name).get_object()
+            self.assertEquals(to_textual.transform(var), complex_to_textual(var))
+        self.assertEquals(to_textual.transform(pymod), complex_to_textual(pymod))
+        enumerate_func = rope.base.builtins.builtins['enumerate'].get_object()
+        self.assertEquals(to_textual.transform(enumerate_func),
+                          complex_to_textual(enumerate_func))
+
+    def test_arguments_with_keywords(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(arg):\n    return arg\n' \
+               'a = a_func(arg=C1())\nb = a_func(arg=C2())\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_a_function_with_different_returns(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(arg):\n    return eval("arg")\n' \
+               'a = a_func(C1())\nb = a_func(C2())\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_a_function_with_different_returns2(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(p):\n    if p == C1:\n        return C1()\n' \
+               '    else:\n        return C2()\n' \
+               'a = a_func(C1)\nb = a_func(C2)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_ignoring_star_args(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(p, *args):\n    if p == C1:\n        return C1()\n' \
+               '    else:\n        return C2()\n' \
+               'a = a_func(C1, 1)\nb = a_func(C2, 2)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_ignoring_double_star_args(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(p, *kwds, **args):\n    if p == C1:\n        return C1()\n' \
+               '    else:\n        return C2()\n' \
+               'a = a_func(C1, kwd=1)\nb = a_func(C2, kwd=2)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        pymod = self.pycore.resource_to_pyobject(mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_invalidating_data_after_changing(self):
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'def a_func(arg):\n    return eval("arg")\n' \
+               'a_var = a_func(a_func)\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        mod.write(code.replace('a_func', 'newfunc'))
+        mod.write(code)
+        pymod = self.pycore.resource_to_pyobject(mod)
+        self.assertNotEquals(pymod.get_attribute('a_func').get_object(),
+                             pymod.get_attribute('a_var').get_object())
+
+    def test_invalidating_data_after_moving(self):
+        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod2.write('class C(object):\n    pass\n')
+        mod = self.pycore.create_module(self.project.root, 'mod')
+        code = 'import mod2\ndef a_func(arg):\n    return eval(arg)\n' \
+               'a_var = a_func("mod2.C")\n'
+        mod.write(code)
+        self.pycore.run_module(mod).wait_process()
+        mod.move('newmod.py')
+        pymod = self.pycore.get_module('newmod')
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        self.assertEquals(pymod2.get_attribute('C').get_object(),
+                          pymod.get_attribute('a_var').get_object())
+
+
+class NewStaticOITest(unittest.TestCase):
+
+    def setUp(self):
+        super(NewStaticOITest, self).setUp()
+        self.project = testutils.sample_project(validate_objectdb=True)
+        self.pycore = self.project.get_pycore()
+        self.mod = self.pycore.create_module(self.project.root, 'mod')
+
+    def tearDown(self):
+        testutils.remove_project(self.project)
+        super(NewStaticOITest, self).tearDown()
+
+    def test_static_oi_for_simple_function_calls(self):
+        code = 'class C(object):\n    pass\ndef f(p):\n    pass\nf(C())\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        f_scope = pymod.get_attribute('f').get_object().get_scope()
+        p_type = f_scope.get_name('p').get_object().get_type()
+        self.assertEquals(c_class, p_type)
+
+    def test_static_oi_not_failing_when_callin_callables(self):
+        code = 'class C(object):\n    pass\nC()\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+
+    def test_static_oi_for_nested_calls(self):
+        code = 'class C(object):\n    pass\ndef f(p):\n    pass\n' \
+               'def g(p):\n    return p\nf(g(C()))\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        f_scope = pymod.get_attribute('f').get_object().get_scope()
+        p_type = f_scope.get_name('p').get_object().get_type()
+        self.assertEquals(c_class, p_type)
+
+    def test_static_oi_class_methods(self):
+        code = 'class C(object):\n    def f(self, p):\n        pass\n' \
+               'C().f(C())'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        f_scope = c_class.get_attribute('f').get_object().get_scope()
+        p_type = f_scope.get_name('p').get_object().get_type()
+        self.assertEquals(c_class, p_type)
+
+    def test_static_oi_preventing_soi_maximum_recursion_exceptions(self):
+        code = 'item = {}\nfor item in item.keys():\n    pass\n'
+        self.mod.write(code)
+        try:
+            self.pycore.analyze_module(self.mod)
+        except RuntimeError, e:
+            self.fail(str(e))
+
+    def test_static_oi_for_infering_returned_types_from_functions_based_on_parameters(self):
+        code = 'class C(object):\n    pass\ndef func(p):\n    return p\n' \
+               'a_var = func(C())\n'
+        self.mod.write(code)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_a_function_with_different_returns(self):
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'def a_func(arg):\n    return arg\n' \
+               'a = a_func(C1())\nb = a_func(C2())\n'
+        self.mod.write(code)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_not_reporting_out_of_date_information(self):
+        code = 'class C1(object):\n    pass\n' \
+               'def f(arg):\n    return C1()\na_var = f('')\n'
+        self.mod.write(code)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+
+        self.mod.write(code.replace('C1', 'C2'))
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c2_class, a_var.get_type())
+
+    def test_invalidating_concluded_data_in_a_function(self):
+        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1.write('def func(arg):\n    temp = arg\n    return temp\n')
+        mod2.write('import mod1\n'
+                   'class C1(object):\n    pass\n'
+                   'class C2(object):\n    pass\n'
+                   'a_var = mod1.func(C1())\n')
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        c1_class = pymod2.get_attribute('C1').get_object()
+        a_var = pymod2.get_attribute('a_var').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+
+        mod2.write(mod2.read()[:mod2.read().rfind('C1()')] + 'C2())\n')
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        c2_class = pymod2.get_attribute('C2').get_object()
+        a_var = pymod2.get_attribute('a_var').get_object()
+        self.assertEquals(c2_class, a_var.get_type())
+
+    def test_handling_generator_functions_for_strs(self):
+        self.mod.write('class C(object):\n    pass\ndef f(p):\n    yield p()\n'
+                       'for c in f(C):\n    a_var = c\n')
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    # TODO: Returning a generator for functions that yield unknowns
+    def xxx_test_handling_generator_functions_when_unknown_type_is_yielded(self):
+        self.mod.write('class C(object):\n    pass\ndef f():\n    yield eval("C()")\n'
+                       'a_var = f()\n')
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertTrue(isinstance(a_var.get_type(),
+                                   rope.base.builtins.Generator))
+
+    def test_static_oi_for_lists_depending_on_append_function(self):
+        code = 'class C(object):\n    pass\nl = list()\n' \
+               'l.append(C())\na_var = l.pop()\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_static_oi_for_lists_per_object_for_get_item(self):
+        code = 'class C(object):\n    pass\nl = list()\n' \
+               'l.append(C())\na_var = l[0]\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_static_oi_for_lists_per_object_for_fields(self):
+        code = 'class C(object):\n    pass\n' \
+               'class A(object):\n    def __init__(self):\n        self.l = []\n' \
+               '    def set(self):\n        self.l.append(C())\n' \
+               'a = A()\na.set()\na_var = a.l[0]\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_static_oi_for_lists_per_object_for_set_item(self):
+        code = 'class C(object):\n    pass\nl = [None]\n' \
+               'l[0] = C()\na_var = l[0]\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_static_oi_for_lists_per_object_for_extending_lists(self):
+        code = 'class C(object):\n    pass\nl = []\n' \
+               'l.append(C())\nl2 = []\nl2.extend(l)\na_var = l2[0]\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_static_oi_for_lists_per_object_for_iters(self):
+        code = 'class C(object):\n    pass\nl = []\n' \
+               'l.append(C())\nfor c in l:\n    a_var = c\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_static_oi_for_dicts_depending_on_append_function(self):
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'd = {}\nd[C1()] = C2()\na, b = d.popitem()\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_static_oi_for_dicts_depending_on_for_loops(self):
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'd = {}\nd[C1()] = C2()\nfor k, v in d.items():\n    a = k\n    b = v\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_static_oi_for_dicts_depending_on_update(self):
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'd = {}\nd[C1()] = C2()\nd2 = {}\nd2.update(d)\na, b = d2.popitem()\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_static_oi_for_dicts_depending_on_update_on_seqs(self):
+        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
+               'd = {}\nd.update([(C1(), C2())])\na, b = d.popitem()\n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        c2_class = pymod.get_attribute('C2').get_object()
+        a_var = pymod.get_attribute('a').get_object()
+        b_var = pymod.get_attribute('b').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEquals(c2_class, b_var.get_type())
+
+    def test_static_oi_for_sets_per_object_for_set_item(self):
+        code = 'class C(object):\n    pass\ns = set()\n' \
+               's.add(C())\na_var = s.pop() \n'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c_class, a_var.get_type())
+
+    def test_properties_and_calling_get_property(self):
+        code = 'class C1(object):\n    pass\n' \
+               'class C2(object):\n    c1 = C1()\n' \
+               '    def get_c1(self):\n        return self.c1\n' \
+               '    p = property(get_c1)\nc2 = C2()\na_var = c2.p\n'
+        self.mod.write(code)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+
+    def test_soi_on_constructors(self):
+        code = 'class C1(object):\n    pass\n' \
+               'class C2(object):\n' \
+               '    def __init__(self, arg):\n        self.attr = arg\n' \
+               'c2 = C2(C1())\na_var = c2.attr'
+        self.mod.write(code)
+        self.pycore.analyze_module(self.mod)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c1_class = pymod.get_attribute('C1').get_object()
+        a_var = pymod.get_attribute('a_var').get_object()
+        self.assertEquals(c1_class, a_var.get_type())
+
+    def test_not_saving_unknown_function_returns(self):
+        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        self.mod.write('class C(object):\n    pass\nl = []\nl.append(C())\n')
+        mod2.write('import mod\ndef f():\n    return mod.l.pop()\na_var = f()\n')
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        c_class = pymod.get_attribute('C').get_object()
+        a_var = pymod2.get_attribute('a_var')
+
+        self.pycore.analyze_module(mod2)
+        self.assertNotEquals(c_class, a_var.get_object().get_type())
+
+        self.pycore.analyze_module(self.mod)
+        self.assertEquals(c_class, a_var.get_object().get_type())
+
+
+def suite():
+    result = unittest.TestSuite()
+    result.addTests(unittest.makeSuite(DynamicOITest))
+    result.addTests(unittest.makeSuite(NewStaticOITest))
+    return result
+
+
+if __name__ == '__main__':
+    unittest.main()

File ropetest/builtintest.py

View file
  • Ignore whitespace
         a_var = pymod.get_attribute('a_var').get_object()
         self.assertTrue(isinstance(a_var.get_type(), builtins.Str))
 
-    def test_file_builtin_type2(self):
+    def test_property_builtin_type(self):
         self.mod.write('p = property()\n')
         pymod = self.pycore.resource_to_pyobject(self.mod)
         p_var = pymod.get_attribute('p').get_object()

File ropetest/historytest.py

View file
  • Ignore whitespace
         self.project.history.undo()
         self.assertFalse(my_file.exists())
 
+    def test_getting_prev_contents(self):
+        my_file = self.project.root.create_file('my_file.txt')
+        self.assertEquals('', self.history.get_prev_contents(my_file))
+
+    def test_getting_prev_contents2(self):
+        my_file = self.project.root.create_file('my_file.txt')
+        my_file.write('1')
+        my_file.write('2')
+        self.assertEquals('1', self.history.get_prev_contents(my_file))
+
 
 class IsolatedHistoryTest(unittest.TestCase):
 

File ropetest/ide/__init__.py

View file
  • Ignore whitespace
 import ropetest.ide.formattertest
 import ropetest.ide.notestest
 import ropetest.ide.outlinetest
-import ropetest.ide.spellcheckertext
+import ropetest.ide.spellcheckertest
 
 
 def suite():

File ropetest/objectinfertest.py

View file
  • Ignore whitespace
 import unittest
 
-import rope.base.project
-from rope.base import builtins
-from rope.base.oi import objectinfo, memorydb, shelvedb, transform
+from rope.base import project, builtins
+from rope.base.oi import memorydb, shelvedb
 from ropetest import testutils
 
 
         self.assertEquals(c_class, a_var.get_type())
 
 
-class NewStaticOITest(unittest.TestCase):
-
-    def setUp(self):
-        super(NewStaticOITest, self).setUp()
-        self.project = testutils.sample_project(validate_objectdb=True)
-        self.pycore = self.project.get_pycore()
-        self.mod = self.pycore.create_module(self.project.root, 'mod')
-
-    def tearDown(self):
-        testutils.remove_project(self.project)
-        super(NewStaticOITest, self).tearDown()
-
-    def test_static_oi_for_simple_function_calls(self):
-        code = 'class C(object):\n    pass\ndef f(p):\n    pass\nf(C())\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        f_scope = pymod.get_attribute('f').get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
-        self.assertEquals(c_class, p_type)
-
-    def test_static_oi_not_failing_when_callin_callables(self):
-        code = 'class C(object):\n    pass\nC()\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-
-    def test_static_oi_for_nested_calls(self):
-        code = 'class C(object):\n    pass\ndef f(p):\n    pass\n' \
-               'def g(p):\n    return p\nf(g(C()))\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        f_scope = pymod.get_attribute('f').get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
-        self.assertEquals(c_class, p_type)
-
-    def test_static_oi_class_methods(self):
-        code = 'class C(object):\n    def f(self, p):\n        pass\n' \
-               'C().f(C())'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        f_scope = c_class.get_attribute('f').get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
-        self.assertEquals(c_class, p_type)
-
-    def test_static_oi_preventing_soi_maximum_recursion_exceptions(self):
-        code = 'item = {}\nfor item in item.keys():\n    pass\n'
-        self.mod.write(code)
-        try:
-            self.pycore.analyze_module(self.mod)
-        except RuntimeError, e:
-            self.fail(str(e))
-
-    def test_static_oi_for_infering_returned_types_from_functions_based_on_parameters(self):
-        code = 'class C(object):\n    pass\ndef func(p):\n    return p\n' \
-               'a_var = func(C())\n'
-        self.mod.write(code)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_a_function_with_different_returns(self):
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'def a_func(arg):\n    return arg\n' \
-               'a = a_func(C1())\nb = a_func(C2())\n'
-        self.mod.write(code)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_not_reporting_out_of_date_information(self):
-        code = 'class C1(object):\n    pass\n' \
-               'def f(arg):\n    return C1()\na_var = f('')\n'
-        self.mod.write(code)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-
-        self.mod.write(code.replace('C1', 'C2'))
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c2_class, a_var.get_type())
-
-    def test_invalidating_concluded_data_in_a_function(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
-        mod1.write('def func(arg):\n    temp = arg\n    return temp\n')
-        mod2.write('import mod1\n'
-                   'class C1(object):\n    pass\n'
-                   'class C2(object):\n    pass\n'
-                   'a_var = mod1.func(C1())\n')
-        pymod2 = self.pycore.resource_to_pyobject(mod2)
-        c1_class = pymod2.get_attribute('C1').get_object()
-        a_var = pymod2.get_attribute('a_var').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-
-        mod2.write(mod2.read()[:mod2.read().rfind('C1()')] + 'C2())\n')
-        pymod2 = self.pycore.resource_to_pyobject(mod2)
-        c2_class = pymod2.get_attribute('C2').get_object()
-        a_var = pymod2.get_attribute('a_var').get_object()
-        self.assertEquals(c2_class, a_var.get_type())
-
-    def test_handling_generator_functions_for_strs(self):
-        self.mod.write('class C(object):\n    pass\ndef f(p):\n    yield p()\n'
-                       'for c in f(C):\n    a_var = c\n')
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    # TODO: Returning a generator for functions that yield unknowns
-    def xxx_test_handling_generator_functions_when_unknown_type_is_yielded(self):
-        self.mod.write('class C(object):\n    pass\ndef f():\n    yield eval("C()")\n'
-                       'a_var = f()\n')
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertTrue(isinstance(a_var.get_type(),
-                                   builtins.Generator))
-
-    def test_static_oi_for_lists_depending_on_append_function(self):
-        code = 'class C(object):\n    pass\nl = list()\n' \
-               'l.append(C())\na_var = l.pop()\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_static_oi_for_lists_per_object_for_get_item(self):
-        code = 'class C(object):\n    pass\nl = list()\n' \
-               'l.append(C())\na_var = l[0]\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_static_oi_for_lists_per_object_for_fields(self):
-        code = 'class C(object):\n    pass\n' \
-               'class A(object):\n    def __init__(self):\n        self.l = []\n' \
-               '    def set(self):\n        self.l.append(C())\n' \
-               'a = A()\na.set()\na_var = a.l[0]\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_static_oi_for_lists_per_object_for_set_item(self):
-        code = 'class C(object):\n    pass\nl = [None]\n' \
-               'l[0] = C()\na_var = l[0]\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_static_oi_for_lists_per_object_for_extending_lists(self):
-        code = 'class C(object):\n    pass\nl = []\n' \
-               'l.append(C())\nl2 = []\nl2.extend(l)\na_var = l2[0]\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_static_oi_for_lists_per_object_for_iters(self):
-        code = 'class C(object):\n    pass\nl = []\n' \
-               'l.append(C())\nfor c in l:\n    a_var = c\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_static_oi_for_dicts_depending_on_append_function(self):
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'd = {}\nd[C1()] = C2()\na, b = d.popitem()\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_static_oi_for_dicts_depending_on_for_loops(self):
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'd = {}\nd[C1()] = C2()\nfor k, v in d.items():\n    a = k\n    b = v\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_static_oi_for_dicts_depending_on_update(self):
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'd = {}\nd[C1()] = C2()\nd2 = {}\nd2.update(d)\na, b = d2.popitem()\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_static_oi_for_dicts_depending_on_update_on_seqs(self):
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'd = {}\nd.update([(C1(), C2())])\na, b = d.popitem()\n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_static_oi_for_sets_per_object_for_set_item(self):
-        code = 'class C(object):\n    pass\ns = set()\n' \
-               's.add(C())\na_var = s.pop() \n'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_properties_and_calling_get_property(self):
-        code = 'class C1(object):\n    pass\n' \
-               'class C2(object):\n    c1 = C1()\n' \
-               '    def get_c1(self):\n        return self.c1\n' \
-               '    p = property(get_c1)\nc2 = C2()\na_var = c2.p\n'
-        self.mod.write(code)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-
-    def test_soi_on_constructors(self):
-        code = 'class C1(object):\n    pass\n' \
-               'class C2(object):\n' \
-               '    def __init__(self, arg):\n        self.attr = arg\n' \
-               'c2 = C2(C1())\na_var = c2.attr'
-        self.mod.write(code)
-        self.pycore.analyze_module(self.mod)
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-
-    def test_not_saving_unknown_function_returns(self):
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
-        self.mod.write('class C(object):\n    pass\nl = []\nl.append(C())\n')
-        mod2.write('import mod\ndef f():\n    return mod.l.pop()\na_var = f()\n')
-        pymod = self.pycore.resource_to_pyobject(self.mod)
-        pymod2 = self.pycore.resource_to_pyobject(mod2)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod2.get_attribute('a_var')
-
-        self.pycore.analyze_module(mod2)
-        self.assertNotEquals(c_class, a_var.get_object().get_type())
-
-        self.pycore.analyze_module(self.mod)
-        self.assertEquals(c_class, a_var.get_object().get_type())
-
-
-class DynamicOITest(unittest.TestCase):
-
-    def setUp(self):
-        super(DynamicOITest, self).setUp()
-        self.project = testutils.sample_project(validate_objectdb=True)
-        self.pycore = self.project.get_pycore()
-
-    def tearDown(self):
-        testutils.remove_project(self.project)
-        super(DynamicOITest, self).tearDown()
-
-    def test_simple_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func(a_func)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod.get_attribute('a_func').get_object(),
-                          pymod.get_attribute('a_var').get_object())
-
-    def test_module_dti(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
-        code = 'import mod1\ndef a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func(mod1)\n'
-        mod2.write(code)
-        self.pycore.run_module(mod2).wait_process()
-        pymod2 = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(self.pycore.resource_to_pyobject(mod1),
-                          pymod2.get_attribute('a_var').get_object())
-
-    def test_class_from_another_module_dti(self):
-        mod1 = self.pycore.create_module(self.project.root, 'mod1')
-        mod2 = self.pycore.create_module(self.project.root, 'mod2')
-        code1 = 'class AClass(object):\n    pass\n'
-        code2 = 'from mod1 import AClass\n' \
-               '\ndef a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func(AClass)\n'
-        mod1.write(code1)
-        mod2.write(code2)
-        self.pycore.run_module(mod2).wait_process()
-        pymod1 = self.pycore.resource_to_pyobject(mod1)
-        pymod2 = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(pymod2.get_attribute('AClass').get_object(),
-                          pymod2.get_attribute('a_var').get_object())
-
-
-    def test_class_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class AClass(object):\n    pass\n' \
-               '\ndef a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func(AClass)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod.get_attribute('AClass').get_object(),
-                          pymod.get_attribute('a_var').get_object())
-
-    def test_instance_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class AClass(object):\n    pass\n' \
-               '\ndef a_func(arg):\n    return eval("arg()")\n' \
-               'a_var = a_func(AClass)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod.get_attribute('AClass').get_object(),
-                          pymod.get_attribute('a_var').get_object().get_type())
-
-    def test_method_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class AClass(object):\n    def a_method(self, arg):\n        return eval("arg()")\n' \
-               'an_instance = AClass()\n' \
-               'a_var = an_instance.a_method(AClass)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod.get_attribute('AClass').get_object(),
-                          pymod.get_attribute('a_var').get_object().get_type())
-
-    def test_function_argument_dti(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func(arg):\n    pass\n' \
-               'a_func(a_func)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
-        self.assertEquals(pyscope.get_name('a_func').get_object(),
-                          pyscope.get_scopes()[0].get_name('arg').get_object())
-
-    def test_classes_with_the_same_name(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func(arg):\n    class AClass(object):\n        pass\n    return eval("arg")\n' \
-               'class AClass(object):\n    pass\n' \
-               'a_var = a_func(AClass)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod.get_attribute('AClass').get_object(),
-                          pymod.get_attribute('a_var').get_object())
-
-    def test_nested_classes(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func():\n    class AClass(object):\n        pass\n    return AClass\n' \
-               'def another_func(arg):\n    return eval("arg")\n' \
-               'a_var = another_func(a_func())\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
-        self.assertEquals(pyscope.get_scopes()[0].get_name('AClass').get_object(),
-                          pyscope.get_name('a_var').get_object())
-
-    def test_function_argument_dti2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func(arg, a_builtin_type):\n    pass\n' \
-               'a_func(a_func, [])\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
-        self.assertEquals(pyscope.get_name('a_func').get_object(),
-                          pyscope.get_scopes()[0].get_name('arg').get_object())
-
-    def test_dti_and_concluded_data_invalidation(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func(a_func)\n'
-        mod.write(code)
-        pymod = self.pycore.resource_to_pyobject(mod)
-        pymod.get_attribute('a_var').get_object()
-        self.pycore.run_module(mod).wait_process()
-        self.assertEquals(pymod.get_attribute('a_func').get_object(),
-                          pymod.get_attribute('a_var').get_object())
-
-    def test_list_objects_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func([C()])[0]\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_for_loops_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
-               'for c in a_func([C()]):\n    a_var = c\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_dict_objects_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C(object):\n    pass\n' \
-               'def a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func({1: C()})[1]\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_dict_keys_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C(object):\n    pass\n' \
-               'def a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func({C(): 1}).keys()[0]\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c_class = pymod.get_attribute('C').get_object()
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertEquals(c_class, a_var.get_type())
-
-    def test_dict_keys_and_dynamicoi2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'def a_func(arg):\n    return eval("arg")\n' \
-               'a, b = a_func((C1(), C2()))\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_strs_and_dynamicoi(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'def a_func(arg):\n    return eval("arg")\n' \
-               'a_var = a_func("hey")\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        a_var = pymod.get_attribute('a_var').get_object()
-        self.assertTrue(isinstance(a_var.get_type(), builtins.Str))
-
-    def test_textual_transformations(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C(object):\n    pass\ndef f():\n    pass\na_var = C()\n' \
-               'a_list = [C()]\na_str = "hey"\na_file = open("file.txt")\n'
-        mod.write(code)
-        to_pyobject = transform.TextualToPyObject(self.project)
-        to_textual = transform.PyObjectToTextual(self.project)
-        pymod = self.pycore.resource_to_pyobject(mod)
-        def complex_to_textual(pyobject):
-            return to_textual.transform(
-                to_pyobject.transform(to_textual.transform(pyobject)))
-        for name in ('C', 'f', 'a_var', 'a_list', 'a_str', 'a_file'):
-            var = pymod.get_attribute(name).get_object()
-            self.assertEquals(to_textual.transform(var), complex_to_textual(var))
-        self.assertEquals(to_textual.transform(pymod), complex_to_textual(pymod))
-        enumerate_func = builtins.builtins['enumerate'].get_object()
-        self.assertEquals(to_textual.transform(enumerate_func),
-                          complex_to_textual(enumerate_func))
-
-    def test_arguments_with_keywords(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'def a_func(arg):\n    return arg\n' \
-               'a = a_func(arg=C1())\nb = a_func(arg=C2())\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_a_function_with_different_returns(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'def a_func(arg):\n    return eval("arg")\n' \
-               'a = a_func(C1())\nb = a_func(C2())\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c1_class = pymod.get_attribute('C1').get_object()
-        c2_class = pymod.get_attribute('C2').get_object()
-        a_var = pymod.get_attribute('a').get_object()
-        b_var = pymod.get_attribute('b').get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
-
-    def test_a_function_with_different_returns2(self):
-        mod = self.pycore.create_module(self.project.root, 'mod')
-        code = 'class C1(object):\n    pass\nclass C2(object):\n    pass\n' \
-               'def a_func(p):\n    if p == C1:\n        return C1()\n' \
-               '    else:\n        return C2()\n' \
-               'a = a_func(C1)\nb = a_func(C2)\n'
-        mod.write(code)
-        self.pycore.run_module(mod).wait_process()
-        pymod = self.pycore.resource_to_pyobject(mod)
-        c1_class = pymod.get_attribute('C1').get_object()