Anonymous avatar Anonymous committed 2aa7f06

using pyscope[name] instead of pyscope.get_name(name)

Comments (0)

Files changed (12)

rope/base/builtins.py

             name = None
             while name is None and scope is not None:
                 for current in scope.get_names():
-                    if scope.get_name(current) is pyname:
+                    if scope[current] is pyname:
                         name = current
                         break
                 else:

rope/base/evaluate.py

         # function header
         if self._is_function_name_in_function_header(holding_scope, offset, lineno):
             name = self.word_finder.get_primary_at(offset).strip()
-            return (None, holding_scope.parent.get_name(name))
+            return (None, holding_scope.parent[name])
         # from statement module
         if self.word_finder.is_from_statement_module(offset):
             module = self.word_finder.get_primary_at(offset)

rope/base/oi/transform.py

                 return None
             if isinstance(pyobject, rope.base.pyobjects.PyDefinedObject):
                 try:
-                    pyobject = pyobject.get_scope().get_name(name).get_object()
+                    pyobject = pyobject.get_scope()[name].get_object()
                 except exceptions.NameNotFoundError:
                     return None
             else:
         module_scope = pymodule.get_scope()
         suspected = None
         if name in module_scope.get_names():
-            suspected = module_scope.get_name(name).get_object()
+            suspected = module_scope[name].get_object()
         if suspected is not None and \
            isinstance(suspected, rope.base.pyobjects.PyClass):
             return suspected

rope/base/pyscopes.py

         """The same as ``get_name(key)``"""
         return self.get_name(key)
 
+    def __contains__(self, key):
+        """The same as ``key in self.get_names()``"""
+        return key in self.get_names()
+
     def get_scopes(self):
         """Return the subscopes of this scope.
 

rope/refactor/importutils/importinfo.py

     def get_imported_primaries(self, context):
         if self.names_and_aliases[0][0] == '*':
             module = self.get_imported_module(context)
-            return [name for name in module.get_attributes().keys()
+            return [name for name in module.get_attributes()
                     if not name.startswith('_')]
         result = []
         for name, alias in self.names_and_aliases:

rope/refactor/move.py

 
     def _get_changes_made_by_new_class(self, dest_attr, new_name):
         old_pyclass = self.pyfunction.parent
-        if dest_attr not in old_pyclass.get_attributes():
+        if dest_attr not in old_pyclass:
             raise exceptions.RefactoringError(
                 'Destination attribute <%s> not found' % dest_attr)
         pyclass = old_pyclass[dest_attr].get_object().get_type()

ropetest/advanced_oi_test.py

 
     def test_method_dti(self):
         mod = testutils.create_module(self.project, 'mod')
-        code = 'class AClass(object):\n    def a_method(self, arg):\n        return eval("arg()")\n' \
+        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)
         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())
+        self.assertEquals(pyscope['a_func'].get_object(),
+                          pyscope.get_scopes()[0]['arg'].get_object())
 
     def test_classes_with_the_same_name(self):
         mod = testutils.create_module(self.project, 'mod')
-        code = 'def a_func(arg):\n    class AClass(object):\n        pass\n    return eval("arg")\n' \
+        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)
 
     def test_nested_classes(self):
         mod = testutils.create_module(self.project, 'mod')
-        code = 'def a_func():\n    class AClass(object):\n        pass\n    return AClass\n' \
+        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())
+        self.assertEquals(pyscope.get_scopes()[0]['AClass'].get_object(),
+                          pyscope['a_var'].get_object())
 
     def test_function_argument_dti2(self):
         mod = testutils.create_module(self.project, 'mod')
         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())
+        self.assertEquals(pyscope['a_func'].get_object(),
+                          pyscope.get_scopes()[0]['arg'].get_object())
 
     def test_dti_and_concluded_data_invalidation(self):
         mod = testutils.create_module(self.project, 'mod')
 
     def test_list_objects_and_dynamicoi(self):
         mod = testutils.create_module(self.project, 'mod')
-        code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
+        code = 'class C(object):\n    pass\n' \
+               'def 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()
 
     def test_for_loops_and_dynamicoi(self):
         mod = testutils.create_module(self.project, 'mod')
-        code = 'class C(object):\n    pass\ndef a_func(arg):\n    return eval("arg")\n' \
+        code = 'class C(object):\n    pass\n' \
+               'def 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(self.mod)
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
+        p_type = f_scope['p'].get_object().get_type()
         self.assertEquals(c_class, p_type)
 
     def test_static_oi_not_failing_when_callin_callables(self):
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
+        p_type = f_scope['p'].get_object().get_type()
         self.assertEquals(c_class, p_type)
 
     def test_static_oi_class_methods(self):
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         f_scope = c_class['f'].get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
+        p_type = f_scope['p'].get_object().get_type()
         self.assertEquals(c_class, p_type)
 
     def test_static_oi_preventing_soi_maximum_recursion_exceptions(self):
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c1_class = pymod['C1'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
-        arg2 = f_scope.get_name('arg2').get_object()
+        arg2 = f_scope['arg2'].get_object()
         self.assertEquals(c1_class, arg2.get_type())
 
     def test_call_function_and_parameters(self):
         self.mod.write(code)
         self.pycore.analyze_module(self.mod)
         scope = self.pycore.resource_to_pyobject(self.mod).get_scope()
-        p_object = scope.get_scopes()[0].get_scopes()[0].\
-                   get_name('p').get_object()
+        p_object = scope.get_scopes()[0].get_scopes()[0]['p'].get_object()
         self.assertTrue(isinstance(p_object.get_type(),
                                    rope.base.builtins.Str))
 
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
-        p_type = f_scope.get_name('p').get_object().get_type()
+        p_type = f_scope['p'].get_object().get_type()
         self.assertEquals(c_class, p_type)
 
     def test_validation_problems_for_objectdb_retrievals(self):
         pymod = self.pycore.resource_to_pyobject(self.mod)
         a_class = pymod['A'].get_object()
         f_scope = a_class.get_scope().get_scopes()[0]
-        p_type = f_scope.get_name('p').get_object().get_type()
+        p_type = f_scope['p'].get_object().get_type()
         self.assertEquals(a_class, p_type)
 
 

ropetest/builtinstest.py

         self.mod.write('def func(p, *args, **kwds):\n    pass\n')
         pymod = self.pycore.resource_to_pyobject(self.mod)
         func_scope = pymod['func'].get_object().get_scope()
-        args = func_scope.get_name('args').get_object()
-        kwds = func_scope.get_name('kwds').get_object()
+        args = func_scope['args'].get_object()
+        kwds = func_scope['kwds'].get_object()
         self.assertTrue(isinstance(args.get_type(), builtins.List))
         self.assertTrue(isinstance(kwds.get_type(), builtins.Dict))
 

ropetest/codeanalyzetest.py

         scope = self.pycore.get_string_scope(code)
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
         result = name_finder.get_pyname_at(len(code) - 3)
-        self.assertEquals(scope.get_name('a_var'), result)
+        self.assertEquals(scope['a_var'], result)
 
     def test_class_variable_attribute_in_class_body(self):
         code = 'a_var = 10\nclass C(object):\n    a_var = a_var\n'
         scope = self.pycore.get_string_scope(code)
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
-        a_var_pyname = scope.get_name('C').\
-                               get_object()['a_var']
+        a_var_pyname = scope['C'].get_object()['a_var']
         result = name_finder.get_pyname_at(len(code) - 12)
         self.assertEquals(a_var_pyname, result)
 
         code = 'a_var = 10\nclass C(object):\n    a_var \\\n= a_var\n'
         scope = self.pycore.get_string_scope(code)
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
-        a_var_pyname = scope.get_name('C').\
-                               get_object()['a_var']
+        a_var_pyname = scope['C'].get_object()['a_var']
         result = name_finder.get_pyname_at(len(code) - 12)
         self.assertEquals(a_var_pyname, result)
 
         code = 'class C(object):\n    def a_method(self):\n        pass\n'
         scope = self.pycore.get_string_scope(code)
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
-        a_method_pyname = scope.get_name('C').\
-                                  get_object()['a_method']
+        a_method_pyname = scope['C'].get_object()['a_method']
         result = name_finder.get_pyname_at(code.index('a_method') + 2)
         self.assertEquals(a_method_pyname, result)
 
         code = 'class C(object):\n    class CC(object):\n        pass\n'
         scope = self.pycore.get_string_scope(code)
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
-        a_class_pyname = scope.get_name('C').get_object()['CC']
+        a_class_pyname = scope['C'].get_object()['CC']
         result = name_finder.get_pyname_at(code.index('CC') + 2)
         self.assertEquals(a_class_pyname, result)
 
     def test_class_method_in_class_body_but_not_indexed(self):
         code = 'class C(object):\n    def func(self, func):\n        pass\n'
         scope = self.pycore.get_string_scope(code)
-        a_func_pyname = scope.get_scopes()[0].get_scopes()[0].get_name('func')
+        a_func_pyname = scope.get_scopes()[0].get_scopes()[0]['func']
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
         result = name_finder.get_pyname_at(code.index(', func') + 3)
         self.assertEquals(a_func_pyname, result)
     def test_function_but_not_indexed(self):
         code = 'def a_func(a_func):\n    pass\n'
         scope = self.pycore.get_string_scope(code)
-        a_func_pyname = scope.get_name('a_func')
+        a_func_pyname = scope['a_func']
         name_finder = rope.base.evaluate.ScopeNameFinder(scope.pyobject)
         result = name_finder.get_pyname_at(code.index('a_func') + 3)
         self.assertEquals(a_func_pyname, result)

ropetest/objectinfertest.py

     def test_simple_type_inferencing(self):
         scope = self.pycore.get_string_scope(
             'class Sample(object):\n    pass\na_var = Sample()\n')
-        sample_class = scope.get_name('Sample').get_object()
-        a_var = scope.get_name('a_var').get_object()
+        sample_class = scope['Sample'].get_object()
+        a_var = scope['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 
     def test_simple_type_inferencing_classes_defined_in_holding_scope(self):
         scope = self.pycore.get_string_scope('class Sample(object):\n    pass\n' +
                                              'def a_func():\n    a_var = Sample()\n')
-        sample_class = scope.get_name('Sample').get_object()
-        a_var = scope.get_name('a_func').get_object().\
-                get_scope().get_name('a_var').get_object()
+        sample_class = scope['Sample'].get_object()
+        a_var = scope['a_func'].get_object().\
+                        get_scope()['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 
     def test_simple_type_inferencing_classes_in_class_methods(self):
                'class Another(object):\n' \
                '    def a_method():\n        a_var = Sample()\n'
         scope = self.pycore.get_string_scope(code)
-        sample_class = scope.get_name('Sample').get_object()
-        another_class = scope.get_name('Another').get_object()
+        sample_class = scope['Sample'].get_object()
+        another_class = scope['Another'].get_object()
         a_var = another_class['a_method'].\
-                get_object().get_scope().get_name('a_var').get_object()
+                        get_object().get_scope()['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 
     def test_simple_type_inferencing_class_attributes(self):
                'class Another(object):\n' \
                '    def __init__(self):\n        self.a_var = Sample()\n'
         scope = self.pycore.get_string_scope(code)
-        sample_class = scope.get_name('Sample').get_object()
-        another_class = scope.get_name('Another').get_object()
+        sample_class = scope['Sample'].get_object()
+        another_class = scope['Another'].get_object()
         a_var = another_class['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 
     def test_simple_type_inferencing_for_in_class_assignments(self):
         scope = self.pycore.get_string_scope('class Sample(object):\n    pass\n' +
                                              'class Another(object):\n    an_attr = Sample()\n')
-        sample_class = scope.get_name('Sample').get_object()
-        another_class = scope.get_name('Another').get_object()
+        sample_class = scope['Sample'].get_object()
+        another_class = scope['Another'].get_object()
         an_attr = another_class['an_attr'].get_object()
         self.assertEquals(sample_class, an_attr.get_type())
 
         mod = 'class Sample(object):\n    pass\n' \
               'copied_sample = Sample'
         mod_scope = self.project.get_pycore().get_string_scope(mod)
-        sample_class = mod_scope.get_name('Sample')
-        copied_sample = mod_scope.get_name('copied_sample')
+        sample_class = mod_scope['Sample']
+        copied_sample = mod_scope['copied_sample']
         self.assertEquals(sample_class.get_object(),
                           copied_sample.get_object())
 
               'sample_class = Sample\n' \
               'sample_class = sample_class\n'
         mod_scope = self.project.get_pycore().get_string_scope(mod)
-        sample_class = mod_scope.get_name('Sample')
-        sample_class_var = mod_scope.get_name('sample_class')
+        sample_class = mod_scope['Sample']
+        sample_class_var = mod_scope['sample_class']
         self.assertEquals(sample_class.get_object(),
                           sample_class_var.get_object())
 
               'def a_func():\n    return Sample\n' \
               'a_var = a_func()\n'
         scope = self.project.get_pycore().get_string_scope(src)
-        sample_class = scope.get_name('Sample')
-        a_var = scope.get_name('a_var')
+        sample_class = scope['Sample']
+        a_var = scope['a_var']
         self.assertEquals(sample_class.get_object(), a_var.get_object())
 
     def test_function_returned_object_static_type_inference2(self):
               'def a_func():\n    return Sample()\n' \
               'a_var = a_func()\n'
         scope = self.project.get_pycore().get_string_scope(src)
-        sample_class = scope.get_name('Sample').get_object()
-        a_var = scope.get_name('a_var').get_object()
+        sample_class = scope['Sample'].get_object()
+        a_var = scope['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 
     def test_recursive_function_returned_object_static_type_inference(self):
               '    else:\n        return a_func()\n' \
               'a_var = a_func()\n'
         scope = self.project.get_pycore().get_string_scope(src)
-        sample_class = scope.get_name('Sample').get_object()
-        a_var = scope.get_name('a_var').get_object()
+        sample_class = scope['Sample'].get_object()
+        a_var = scope['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 
     def test_function_returned_object_using_call_special_function_static_type_inference(self):
               '    def __call__(self):\n        return Sample\n' \
               'sample = Sample()\na_var = sample()'
         scope = self.project.get_pycore().get_string_scope(src)
-        sample_class = scope.get_name('Sample')
-        a_var = scope.get_name('a_var')
+        sample_class = scope['Sample']
+        a_var = scope['a_var']
         self.assertEquals(sample_class.get_object(), a_var.get_object())
 
     def test_list_type_inferencing(self):
         src = 'class Sample(object):\n    pass\na_var = [Sample()]\n'
         scope = self.pycore.get_string_scope(src)
-        sample_class = scope.get_name('Sample').get_object()
-        a_var = scope.get_name('a_var').get_object()
+        sample_class = scope['Sample'].get_object()
+        a_var = scope['a_var'].get_object()
         self.assertNotEquals(sample_class, a_var.get_type())
 
     def test_attributed_object_inference(self):
               '    def __init__(self):\n        self.a_var = None\n' \
               '    def set(self):\n        self.a_var = Sample()\n'
         scope = self.pycore.get_string_scope(src)
-        sample_class = scope.get_name('Sample').get_object()
+        sample_class = scope['Sample'].get_object()
         a_var = sample_class['a_var'].get_object()
         self.assertEquals(sample_class, a_var.get_type())
 

ropetest/pycoretest.py

         self.assertTrue('var' in scope.get_names())
 
     def test_inheriting_base_class_attributes(self):
-        mod = self.pycore.get_string_module('class Base(object):\n    def method(self):\n        pass\n' +
-                                             'class Derived(Base):\n    pass\n')
+        mod = self.pycore.get_string_module(
+            'class Base(object):\n    def method(self):\n        pass\n'
+            'class Derived(Base):\n    pass\n')
         derived = mod['Derived'].get_object()
         self.assertTrue('method' in derived)
         self.assertEquals(get_base_type('Function'),
     def test_get_pyname_definition_location_local_variables(self):
         mod = self.pycore.get_string_module('def a_func():\n    a_var = 10\n')
         a_func_scope = mod.get_scope().get_scopes()[0]
-        a_var = a_func_scope.get_name('a_var')
+        a_var = a_func_scope['a_var']
         self.assertEquals((mod, 2), a_var.get_definition_location())
 
     def test_get_pyname_definition_location_reassigning(self):
     def test_get_pyname_definition_location_parameters(self):
         mod = self.pycore.get_string_module('def a_func(param1, param2):\n    a_var = param\n')
         a_func_scope = mod.get_scope().get_scopes()[0]
-        param1 = a_func_scope.get_name('param1')
+        param1 = a_func_scope['param1']
         self.assertEquals((mod, 1), param1.get_definition_location())
-        param2 = a_func_scope.get_name('param2')
+        param2 = a_func_scope['param2']
         self.assertEquals((mod, 1), param2.get_definition_location())
 
     def test_module_get_resource(self):
         self.assertEquals(None, string_module.get_resource())
 
     def test_get_pyname_definition_location_class2(self):
-        mod = self.pycore.get_string_module('class AClass(object):\n    def __init__(self):\n' + \
-                                            '        self.an_attr = 10\n')
+        mod = self.pycore.get_string_module(
+            'class AClass(object):\n    def __init__(self):\n'
+            '        self.an_attr = 10\n')
         a_class = mod['AClass'].get_object()
         an_attr = a_class['an_attr']
         self.assertEquals((mod, 3), an_attr.get_definition_location())
 
     def test_out_of_project_modules(self):
         scope = self.pycore.get_string_scope('import rope.base.project as project\n')
-        imported_module = scope.get_name('project').get_object()
+        imported_module = scope['project'].get_object()
         self.assertTrue('Project' in imported_module)
 
     def test_file_encoding_reading(self):
         mod = self.pycore.get_string_module(contents)
         global_var = mod['a_var']
         func_scope = mod['a_func'].get_object().get_scope()
-        local_var = func_scope.get_name('a_var')
+        local_var = func_scope['a_var']
         self.assertEquals(global_var, local_var)
 
     def test_not_leaking_for_vars_inside_parent_scope(self):
         self.project = testutils.sample_project()
         self.pycore = self.project.get_pycore()
         samplemod = testutils.create_module(self.project, 'samplemod')
-        samplemod.write("class SampleClass(object):\n    def sample_method():\n        pass" + \
-                        "\n\ndef sample_func():\n    pass\nsample_var = 10\n" + \
-                        "\ndef _underlined_func():\n    pass\n\n")
+        samplemod.write(
+            'class SampleClass(object):\n    def sample_method():\n        pass'
+            '\n\ndef sample_func():\n    pass\nsample_var = 10\n'
+            '\ndef _underlined_func():\n    pass\n\n')
         package = testutils.create_package(self.project, 'package')
         nestedmod = testutils.create_module(self.project, 'nestedmod', package)
 
     def test_from_import_function(self):
         scope = self.pycore.get_string_scope('def f():\n    from samplemod import SampleClass\n')
         self.assertEquals(get_base_type('Type'),
-                          scope.get_scopes()[0].get_name('SampleClass').
+                          scope.get_scopes()[0]['SampleClass'].
                           get_object().get_type())
 
     def test_circular_imports(self):
         pymod = self.pycore.get_module('mod')
         self.assertTrue('a_var' in pymod['pkg1'].get_object()['pkg2'].get_object())
         init_dot_py.write('new_var = 10\n')
-        self.assertTrue('a_var' not in pymod['pkg1'].get_object()['pkg2'].get_object().get_attributes())
+        self.assertTrue('a_var' not in pymod['pkg1'].get_object()['pkg2'].get_object())
 
     def test_from_import_nonexistent_module(self):
         mod = self.pycore.get_string_module('from doesnotexistmod import DoesNotExistClass\n')
         self.assertTrue('sample_method' in derived)
 
     def test_self_in_methods(self):
-        scope = self.pycore.get_string_scope('class Sample(object):\n' \
-                                             '    def func(self):\n        pass\n')
-        sample_class = scope.get_name('Sample').get_object()
+        scope = self.pycore.get_string_scope(
+            'class Sample(object):\n'
+            '    def func(self):\n        pass\n')
+        sample_class = scope['Sample'].get_object()
         func_scope = scope.get_scopes()[0].get_scopes()[0]
         self.assertEquals(sample_class,
-                          func_scope.get_name('self').get_object().get_type())
-        self.assertTrue('func' in func_scope.get_name('self').
+                          func_scope['self'].get_object().get_type())
+        self.assertTrue('func' in func_scope['self'].
                                 get_object())
 
     def test_none_assignments_in_classes(self):
         scope = self.pycore.get_string_scope(
             'class C(object):\n    var = ""\n'
             '    def f(self):\n        self.var += "".join([])\n')
-        c_class = scope.get_name('C').get_object()
+        c_class = scope['C'].get_object()
         self.assertTrue('var' in c_class)
 
     def test_self_in_methods_with_decorators(self):
         scope = self.pycore.get_string_scope('class Sample(object):\n    @staticmethod\n' +
                                              '    def func(self):\n        pass\n')
-        sample_class = scope.get_name('Sample').get_object()
+        sample_class = scope['Sample'].get_object()
         func_scope = scope.get_scopes()[0].get_scopes()[0]
         self.assertNotEquals(sample_class,
-                             func_scope.get_name('self').get_object().get_type())
+                             func_scope['self'].get_object().get_type())
 
     def test_location_of_imports_when_importing(self):
         mod = testutils.create_module(self.project, 'mod')
         mod.write('from samplemod import SampleClass\n')
         scope = self.pycore.get_string_scope('from mod import SampleClass\n')
-        sample_class = scope.get_name('SampleClass')
+        sample_class = scope['SampleClass']
         samplemod = self.pycore.get_module('samplemod')
         self.assertEquals((samplemod, 1), sample_class.get_definition_location())
 
         mod = testutils.create_module(self.project, 'mod', pkg)
         imported_module = self.pycore.get_module('pkg.mod')
         scope = self.pycore.get_string_scope('import pkg.mod\n')
-        mod_pyobject = scope.get_name('pkg').get_object()['mod']
+        mod_pyobject = scope['pkg'].get_object()['mod']
         self.assertEquals((imported_module, 1),
                           mod_pyobject.get_definition_location())
 
         mod2.write('import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_scope = self.pycore.get_string_scope(mod2.read(), mod2)
-        self.assertEquals(mod1_object, mod2_scope.get_name('mod1').get_object())
+        self.assertEquals(mod1_object, mod2_scope['mod1'].get_object())
 
     @testutils.run_only_for_25
     def test_new_style_relative_imports(self):

ropetest/pyscopestest.py

 
     def test_simple_scope(self):
         scope = self.pycore.get_string_scope('def sample_func():\n    pass\n')
-        sample_func = scope.get_name('sample_func').get_object()
+        sample_func = scope['sample_func'].get_object()
         self.assertEquals(get_base_type('Function'), sample_func.get_type())
 
     def test_simple_function_scope(self):
         self.assertEquals(1, len(scope.get_scopes()))
         sample_func_scope = scope.get_scopes()[0]
         self.assertEquals(get_base_type('Type'),
-                          scope.get_scopes()[0].
-                          get_name('SampleClass').get_object().get_type())
+                          scope.get_scopes()[0]['SampleClass'].get_object().get_type())
 
     def test_simple_class_scope(self):
         scope = self.pycore.get_string_scope(
         code = 'class AClass(object):\n' \
                '    def a_func(self, param):\n        pass\n'
         a_class = self.pycore.get_string_module(code)['AClass']. get_object()
-        function_scope = a_class['a_func'].\
-                         get_object().get_scope()
-        self.assertEquals(a_class, function_scope.
-                          get_name('self').get_object().get_type())
-        self.assertNotEquals(a_class, function_scope.get_name('param').
+        function_scope = a_class['a_func'].get_object().get_scope()
+        self.assertEquals(a_class, function_scope['self'].get_object().get_type())
+        self.assertNotEquals(a_class, function_scope['param'].
                              get_object().get_type())
 
     def test_first_parameter_of_static_methods(self):
         a_class = self.pycore.get_string_module(code)['AClass']. get_object()
         function_scope = a_class['a_func'].\
                          get_object().get_scope()
-        self.assertNotEquals(a_class, function_scope.
-                             get_name('param').get_object().get_type())
+        self.assertNotEquals(a_class, function_scope['param'].get_object().get_type())
 
     def test_first_parameter_of_class_methods(self):
         code = 'class AClass(object):\n' \
             '    @classmethod\n    def a_func(cls):\n        pass\n'
         a_class = self.pycore.get_string_module(code)['AClass']. get_object()
-        function_scope = a_class['a_func'].\
-                         get_object().get_scope()
-        self.assertEquals(a_class, function_scope.get_name('cls').get_object())
+        function_scope = a_class['a_func'].get_object().get_scope()
+        self.assertEquals(a_class, function_scope['cls'].get_object())
 
     def test_first_parameter_with_self_as_name_and_unknown_decorator(self):
         code = 'def my_decorator(func):\n    return func\n'\
                'class AClass(object):\n' \
                '    @my_decorator\n    def a_func(self):\n        pass\n'
         a_class = self.pycore.get_string_module(code)['AClass']. get_object()
-        function_scope = a_class['a_func'].\
-                         get_object().get_scope()
-        self.assertEquals(a_class, function_scope.get_name('self').
+        function_scope = a_class['a_func'].get_object().get_scope()
+        self.assertEquals(a_class, function_scope['self'].
                           get_object().get_type())
 
     def test_inside_class_scope_attribute_lookup(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.