zjes avatar zjes committed 6895c26

Fix ast.with issue for python version since 3.3

Comments (0)

Files changed (6)

rope/base/oi/runmod.py

                 if len(object_) > 0:
                     keys = list(object_.keys())[0]
                     values = object_[keys]
+                    if values == object_ and len(object_) > 1:
+                        keys = list(object_.keys())[1]
+                        values = object_[keys]
                 return ('builtin', 'dict',
                         self._object_to_persisted_form(keys),
                         self._object_to_persisted_form(values))

rope/base/pyobjectsdef.py

+import sys
 import rope.base.codeanalyze
 import rope.base.evaluate
 import rope.base.builtins
                        astutils, pyobjects, fscommands, arguments, utils)
 from rope.base.pyobjects import *
 
-
 class PyFunction(pyobjects.PyFunction):
 
     def __init__(self, pycore, ast_node, parent):
         return result
 
     def _With(self, node):
-        if node.optional_vars:
-            self._update_evaluated(node.optional_vars,
-                                   node.context_expr, '.__enter__()')
+        if (sys.version_info[1] < 3):
+            if node.optional_vars:
+                self._update_evaluated(node.optional_vars,
+                                       node.context_expr, '.__enter__()')
+        elif len(node.items) > 0:
+            #TODO Handle all items?
+            if node.items[0].optional_vars:
+                self._update_evaluated(
+                    node.items[0].optional_vars,
+                    node.items[0].context_expr, 
+                    '.__enter__()'
+                )
+                                
         for child in node.body:
             ast.walk(child, self)
 

ropetest/contrib/autoimporttest.py

         super(AutoImportTest, self).tearDown()
 
     def test_simple_case(self):
-        self.assertEquals([], self.importer.import_assist('A'))
+        self.assertEqual([], self.importer.import_assist('A'))
 
     def test_update_resource(self):
         self.mod1.write('myvar = None\n')
         self.importer.update_resource(self.mod1)
-        self.assertEquals([('myvar', 'mod1')],
+        self.assertEqual([('myvar', 'mod1')],
                           self.importer.import_assist('myva'))
 
     def test_update_module(self):
         self.mod1.write('myvar = None')
         self.importer.update_module('mod1')
-        self.assertEquals([('myvar', 'mod1')],
+        self.assertEqual([('myvar', 'mod1')],
                           self.importer.import_assist('myva'))
 
     def test_update_non_existent_module(self):
         self.importer.update_module('does_not_exists_this')
-        self.assertEquals([], self.importer.import_assist('myva'))
+        self.assertEqual([], self.importer.import_assist('myva'))
 
     def test_module_with_syntax_errors(self):
         self.mod1.write('this is a syntax error\n')
         self.importer.update_resource(self.mod1)
-        self.assertEquals([], self.importer.import_assist('myva'))
+        self.assertEqual([], self.importer.import_assist('myva'))
 
     def test_excluding_imported_names(self):
         self.mod1.write('import pkg\n')
         self.importer.update_resource(self.mod1)
-        self.assertEquals([], self.importer.import_assist('pkg'))
+        self.assertEqual([], self.importer.import_assist('pkg'))
 
     def test_get_modules(self):
         self.mod1.write('myvar = None\n')
         self.importer.update_resource(self.mod1)
-        self.assertEquals(['mod1'], self.importer.get_modules('myvar'))
+        self.assertEqual(['mod1'], self.importer.get_modules('myvar'))
 
     def test_get_modules_inside_packages(self):
         self.mod1.write('myvar = None\n')
         self.mod2.write('myvar = None\n')
         self.importer.update_resource(self.mod1)
         self.importer.update_resource(self.mod2)
-        self.assertEquals(set(['mod1', 'pkg.mod2']),
+        self.assertEqual(set(['mod1', 'pkg.mod2']),
                           set(self.importer.get_modules('myvar')))
 
     def test_trivial_insertion_line(self):
         result = self.importer.find_insertion_line('')
-        self.assertEquals(1, result)
+        self.assertEqual(1, result)
 
     def test_insertion_line(self):
         result = self.importer.find_insertion_line('import mod\n')
-        self.assertEquals(2, result)
+        self.assertEqual(2, result)
 
     def test_insertion_line_with_pydocs(self):
         result = self.importer.find_insertion_line(
             '"""docs\n\ndocs"""\nimport mod\n')
-        self.assertEquals(5, result)
+        self.assertEqual(5, result)
 
     def test_insertion_line_with_multiple_imports(self):
         result = self.importer.find_insertion_line(
             'import mod1\n\nimport mod2\n')
-        self.assertEquals(4, result)
+        self.assertEqual(4, result)
 
     def test_insertion_line_with_blank_lines(self):
         result = self.importer.find_insertion_line(
             'import mod1\n\n# comment\n')
-        self.assertEquals(2, result)
+        self.assertEqual(2, result)
 
     def test_empty_cache(self):
         self.mod1.write('myvar = None\n')
         self.importer.update_resource(self.mod1)
-        self.assertEquals(['mod1'], self.importer.get_modules('myvar'))
+        self.assertEqual(['mod1'], self.importer.get_modules('myvar'))
         self.importer.clear_cache()
-        self.assertEquals([], self.importer.get_modules('myvar'))
+        self.assertEqual([], self.importer.get_modules('myvar'))
 
     def test_not_caching_underlined_names(self):
         self.mod1.write('_myvar = None\n')
         self.importer.update_resource(self.mod1, underlined=False)
-        self.assertEquals([], self.importer.get_modules('_myvar'))
+        self.assertEqual([], self.importer.get_modules('_myvar'))
         self.importer.update_resource(self.mod1, underlined=True)
-        self.assertEquals(['mod1'], self.importer.get_modules('_myvar'))
+        self.assertEqual(['mod1'], self.importer.get_modules('_myvar'))
 
     def test_caching_underlined_names_passing_to_the_constructor(self):
         importer = autoimport.AutoImport(self.project, False, True)
         self.mod1.write('_myvar = None\n')
         importer.update_resource(self.mod1)
-        self.assertEquals(['mod1'], importer.get_modules('_myvar'))
+        self.assertEqual(['mod1'], importer.get_modules('_myvar'))
 
     def test_name_locations(self):
         self.mod1.write('myvar = None\n')
         self.importer.update_resource(self.mod1)
-        self.assertEquals([(self.mod1, 1)],
+        self.assertEqual([(self.mod1, 1)],
                           self.importer.get_name_locations('myvar'))
 
     def test_name_locations_with_multiple_occurrences(self):
         self.mod2.write('\nmyvar = None\n')
         self.importer.update_resource(self.mod1)
         self.importer.update_resource(self.mod2)
-        self.assertEquals(set([(self.mod1, 1), (self.mod2, 2)]),
+        self.assertEqual(set([(self.mod1, 1), (self.mod2, 2)]),
                           set(self.importer.get_name_locations('myvar')))
 
     def test_handling_builtin_modules(self):
         self.assertTrue('sys' in self.importer.get_modules('exit'))
 
     def test_submodules(self):
-        self.assertEquals(set([self.mod1]),
+        self.assertEqual(set([self.mod1]),
                           autoimport.submodules(self.mod1))
-        self.assertEquals(set([self.mod2, self.pkg]),
+        self.assertEqual(set([self.mod2, self.pkg]),
                           autoimport.submodules(self.pkg))
 
 class AutoImportObservingTest(unittest.TestCase):
 
     def test_writing_files(self):
         self.mod1.write('myvar = None\n')
-        self.assertEquals(['mod1'], self.importer.get_modules('myvar'))
+        self.assertEqual(['mod1'], self.importer.get_modules('myvar'))
 
     def test_moving_files(self):
         self.mod1.write('myvar = None\n')
         self.mod1.move('mod3.py')
-        self.assertEquals(['mod3'], self.importer.get_modules('myvar'))
+        self.assertEqual(['mod3'], self.importer.get_modules('myvar'))
 
     def test_removing_files(self):
         self.mod1.write('myvar = None\n')
         self.mod1.remove()
-        self.assertEquals([], self.importer.get_modules('myvar'))
+        self.assertEqual([], self.importer.get_modules('myvar'))
 
 
 def suite():

ropetest/contrib/changestacktest.py

         myfile.write('1')
         stack = rope.contrib.changestack.ChangeStack(self.project)
         stack.push(ChangeContents(myfile, '2'))
-        self.assertEquals('2', myfile.read())
+        self.assertEqual('2', myfile.read())
         stack.push(ChangeContents(myfile, '3'))
-        self.assertEquals('3', myfile.read())
+        self.assertEqual('3', myfile.read())
         stack.pop_all()
-        self.assertEquals('1', myfile.read())
+        self.assertEqual('1', myfile.read())
         changes = stack.merged()
         self.project.do(changes)
-        self.assertEquals('3', myfile.read())
+        self.assertEqual('3', myfile.read())
 
 
 if __name__ == '__main__':

ropetest/contrib/codeassisttest.py

         result = self._assist(code)
         count = len([x for x in result
                      if x.name == 'variable' and x.scope == 'global'])
-        self.assertEquals(1, count)
+        self.assertEqual(1, count)
 
     @testutils.assert_raises(exceptions.ModuleSyntaxError)
     def test_throwing_exception_in_case_of_syntax_errors(self):
 
     def test_completion_result(self):
         code = 'my_global = 10\nt = my'
-        self.assertEquals(len(code) - 2, starting_offset(code, len(code)))
+        self.assertEqual(len(code) - 2, starting_offset(code, len(code)))
 
     def test_completing_imported_names(self):
         code = 'import sys\na = sy'
     def test_get_definition_location(self):
         code = 'def a_func():\n    pass\na_func()'
         result = get_definition_location(self.project, code, len(code) - 3)
-        self.assertEquals((None, 1), result)
+        self.assertEqual((None, 1), result)
 
     def test_get_definition_location_underlined_names(self):
         code = 'def a_sample_func():\n    pass\na_sample_func()'
         result = get_definition_location(self.project, code, len(code) - 11)
-        self.assertEquals((None, 1), result)
+        self.assertEqual((None, 1), result)
 
     def test_get_definition_location_dotted_names(self):
         code = 'class AClass(object):\n' \
                '        pass\n' \
                'AClass.a_method()'
         result = get_definition_location(self.project, code, len(code) - 3)
-        self.assertEquals((None, 2), result)
+        self.assertEqual((None, 2), result)
 
     def test_get_definition_location_dotted_module_names(self):
         module_resource = testutils.create_module(self.project, 'mod')
         module_resource.write('def a_func():\n    pass\n')
         code = 'import mod\nmod.a_func()'
         result = get_definition_location(self.project, code, len(code) - 3)
-        self.assertEquals((module_resource, 1), result)
+        self.assertEqual((module_resource, 1), result)
 
     def test_get_definition_location_for_nested_packages(self):
         pycore = self.project.pycore
         init_dot_py = pkg2.get_child('__init__.py')
         found_pyname = get_definition_location(self.project, mod1.read(),
                                                mod1.read().index('pkg2') + 1)
-        self.assertEquals(init_dot_py, found_pyname[0])
+        self.assertEqual(init_dot_py, found_pyname[0])
 
     def test_get_definition_location_unknown(self):
         code = 'a_func()\n'
         result = get_definition_location(self.project, code, len(code) - 3)
-        self.assertEquals((None, None), result)
+        self.assertEqual((None, None), result)
 
     def test_get_definition_location_dot_spaces(self):
         code = 'class AClass(object):\n    ' \
                '@staticmethod\n    def a_method():\n' \
                '        pass\nAClass.\\\n     a_method()'
         result = get_definition_location(self.project, code, len(code) - 3)
-        self.assertEquals((None, 2), result)
+        self.assertEqual((None, 2), result)
 
     def test_get_definition_location_dot_line_break_inside_parens(self):
         code = 'class A(object):\n    def a_method(self):\n        pass\n' + \
                '(A.\na_method)'
         result = get_definition_location(self.project, code,
                                          code.rindex('a_method') + 1)
-        self.assertEquals((None, 2), result)
+        self.assertEqual((None, 2), result)
 
     def test_if_scopes_in_other_scopes_for_get_definition_location(self):
         code = 'def f(a_var):\n    pass\na_var = 10\nif True:\n    print a_var\n'
         result = get_definition_location(self.project, code, len(code) - 3)
-        self.assertEquals((None, 3), result)
+        self.assertEqual((None, 3), result)
 
     def test_code_assists_in_parens(self):
         code = 'def a_func(a_var):\n    pass\na_var = 10\na_func(a_'
                '    my_sample_var = 20\n' + \
                '    my_sample_'
         proposals = sorted_proposals(self._assist(code))
-        self.assertEquals('my_sample_var', proposals[0].name)
-        self.assertEquals('my_sample_function', proposals[1].name)
+        self.assertEqual('my_sample_var', proposals[0].name)
+        self.assertEqual('my_sample_function', proposals[1].name)
 
     def test_proposals_sorter_for_methods_and_attributes(self):
         code = 'class A(object):\n' + \
                'a_var = A()\n' + \
                'a_var.my_'
         proposals = sorted_proposals(self._assist(code))
-        self.assertEquals('my_b_func', proposals[0].name)
-        self.assertEquals('my_c_func', proposals[1].name)
-        self.assertEquals('my_a_var', proposals[2].name)
+        self.assertEqual('my_b_func', proposals[0].name)
+        self.assertEqual('my_c_func', proposals[1].name)
+        self.assertEqual('my_a_var', proposals[2].name)
 
     def test_proposals_sorter_for_global_methods_and_funcs(self):
         code = 'def my_b_func(self):\n' + \
                'my_a_var = 10\n' + \
                'my_'
         proposals = sorted_proposals(self._assist(code))
-        self.assertEquals('my_b_func', proposals[0].name)
-        self.assertEquals('my_a_var', proposals[1].name)
+        self.assertEqual('my_b_func', proposals[0].name)
+        self.assertEqual('my_a_var', proposals[1].name)
 
     def test_proposals_sorter_underlined_methods(self):
         code = 'class A(object):\n' + \
                'a_var = A()\n' + \
                'a_var.'
         proposals = sorted_proposals(self._assist(code))
-        self.assertEquals('my_func', proposals[0].name)
-        self.assertEquals('_my_func', proposals[1].name)
+        self.assertEqual('my_func', proposals[0].name)
+        self.assertEqual('_my_func', proposals[1].name)
 
     def test_proposals_sorter_and_scope_prefs(self):
         code = 'my_global_var = 1\n' \
                '    my_'
         result = self._assist(code)
         proposals = sorted_proposals(result, scopepref=['global', 'local'])
-        self.assertEquals('my_global_var', proposals[0].name)
-        self.assertEquals('my_local_var', proposals[1].name)
+        self.assertEqual('my_global_var', proposals[0].name)
+        self.assertEqual('my_local_var', proposals[1].name)
 
     def test_proposals_sorter_and_type_prefs(self):
         code = 'my_global_var = 1\n' \
                'my_'
         result = self._assist(code)
         proposals = sorted_proposals(result, typepref=['instance', 'function'])
-        self.assertEquals('my_global_var', proposals[0].name)
-        self.assertEquals('my_global_func', proposals[1].name)
+        self.assertEqual('my_global_var', proposals[0].name)
+        self.assertEqual('my_global_func', proposals[1].name)
 
     def test_proposals_sorter_and_missing_type_in_typepref(self):
         code = 'my_global_var = 1\n' \
         mod = testutils.create_module(self.project, 'mod')
         mod.write('"""a module"""\n')
         src = 'import mod\nmod'
-        self.assertEquals('a module', get_doc(self.project, src, len(src) - 1))
+        self.assertEqual('a module', get_doc(self.project, src, len(src) - 1))
 
     def test_get_pydoc_for_builtins(self):
         src = 'print(object)\n'
     def test_simple_get_calltips(self):
         src = 'def f():\n    pass\nvar = f()\n'
         doc = get_calltip(self.project, src, src.rindex('f'))
-        self.assertEquals('f()', doc)
+        self.assertEqual('f()', doc)
 
     def test_get_calltips_for_classes(self):
         src = 'class C(object):\n' \
               '    def __init__(self):\n        pass\nC('
         doc = get_calltip(self.project, src, len(src) - 1)
-        self.assertEquals('C.__init__(self)', doc)
+        self.assertEqual('C.__init__(self)', doc)
 
     def test_get_calltips_for_objects_with_call(self):
         src = 'class C(object):\n' \
               '    def __call__(self, p):\n        pass\n' \
               'c = C()\nc(1,'
         doc = get_calltip(self.project, src, src.rindex('c'))
-        self.assertEquals('C.__call__(self, p)', doc)
+        self.assertEqual('C.__call__(self, p)', doc)
 
     def test_get_calltips_and_including_module_name(self):
         src = 'class C(object):\n' \
         mod = testutils.create_module(self.project, 'mod')
         mod.write(src)
         doc = get_calltip(self.project, src, src.rindex('c'), mod)
-        self.assertEquals('mod.C.__call__(self, p)', doc)
+        self.assertEqual('mod.C.__call__(self, p)', doc)
 
     def test_get_calltips_and_including_module_name(self):
         src = 'range()\n'
               '        pass\n' \
               'C().f()'
         doc = get_calltip(self.project, src, src.rindex('f'), remove_self=True)
-        self.assertEquals('C.f()', doc)
+        self.assertEqual('C.f()', doc)
 
     def test_removing_self_parameter_and_more_than_one_parameter(self):
         src = 'class C(object):\n' \
               '        pass\n' \
               'C().f()'
         doc = get_calltip(self.project, src, src.rindex('f'), remove_self=True)
-        self.assertEquals('C.f(p1)', doc)
+        self.assertEqual('C.f(p1)', doc)
 
     def test_lambda_calltip(self):
         src = 'foo = lambda x, y=1: None\n' \
                '    def method1(self):\n' \
                '        pass\n' \
                'Sample.me'
-        self.assertEquals(len(code) - 2, starting_offset(code, len(code)))
+        self.assertEqual(len(code) - 2, starting_offset(code, len(code)))
 
     def test_backslash_after_dots(self):
         code = 'class Sample(object):\n' \
         code = 'import mod1\nmod1.a_func\n'
         result = get_definition_location(self.project, code,
                                          len(code) - 2, mod2)
-        self.assertEquals((mod1, 1), result)
+        self.assertEqual((mod1, 1), result)
 
     def test_get_definition_location_for_builtins(self):
         code = 'import sys\n'
         result = get_definition_location(self.project, code,
                                          len(code) - 2)
-        self.assertEquals((None, None), result)
+        self.assertEqual((None, None), result)
 
     def test_get_doc_on_relative_imports(self):
         pkg = testutils.create_package(self.project, 'pkg')
 
     def test_starting_expression(self):
         code = 'l = list()\nl.app'
-        self.assertEquals('l.app', starting_expression(code, len(code)))
+        self.assertEqual('l.app', starting_expression(code, len(code)))
 
+    def test_with_variable_completion_proposal(self):
+        code = 'def test_with_statement():\n  with open("output.txt", "w") as fout:\n    ' \
+               'fo'
+        result = self._assist(code)
+        self.assert_completion_in_result('fout', 'local', result)
 
 def suite():
     result = unittest.TestSuite()

ropetest/pycoretest.py

     def test_simple_module(self):
         testutils.create_module(self.project, 'mod')
         result = self.pycore.get_module('mod')
-        self.assertEquals(get_base_type('Module'), result.type)
-        self.assertEquals(0, len(result.get_attributes()))
+        self.assertEqual(get_base_type('Module'), result.type)
+        self.assertEqual(0, len(result.get_attributes()))
 
     def test_nested_modules(self):
         pkg = testutils.create_package(self.project, 'pkg')
         mod = testutils.create_module(self.project, 'mod', pkg)
         package = self.pycore.get_module('pkg')
-        self.assertEquals(get_base_type('Module'), package.get_type())
-        self.assertEquals(1, len(package.get_attributes()))
+        self.assertEqual(get_base_type('Module'), package.get_type())
+        self.assertEqual(1, len(package.get_attributes()))
         module = package['mod'].get_object()
-        self.assertEquals(get_base_type('Module'), module.get_type())
+        self.assertEqual(get_base_type('Module'), module.get_type())
 
     def test_package(self):
         pkg = testutils.create_package(self.project, 'pkg')
         mod = testutils.create_module(self.project, 'mod', pkg)
         result = self.pycore.get_module('pkg')
-        self.assertEquals(get_base_type('Module'), result.type)
+        self.assertEqual(get_base_type('Module'), result.type)
 
     def test_simple_class(self):
         mod = testutils.create_module(self.project, 'mod')
         mod.write('class SampleClass(object):\n    pass\n')
         mod_element = self.pycore.get_module('mod')
         result = mod_element['SampleClass'].get_object()
-        self.assertEquals(get_base_type('Type'), result.get_type())
+        self.assertEqual(get_base_type('Type'), result.get_type())
 
     def test_simple_function(self):
         mod = testutils.create_module(self.project, 'mod')
         mod.write('def sample_function():\n    pass\n')
         mod_element = self.pycore.get_module('mod')
         result = mod_element['sample_function'].get_object()
-        self.assertEquals(get_base_type('Function'), result.get_type())
+        self.assertEqual(get_base_type('Function'), result.get_type())
 
     def test_class_methods(self):
         mod = testutils.create_module(self.project, 'mod')
         sample_class = mod_element['SampleClass'].get_object()
         self.assertTrue('sample_method' in sample_class)
         method = sample_class['sample_method'].get_object()
-        self.assertEquals(get_base_type('Function'), method.get_type())
+        self.assertEqual(get_base_type('Function'), method.get_type())
 
     def test_global_variables(self):
         mod = testutils.create_module(self.project, 'mod')
         mod_element = self.pycore.get_module('mod')
         sample_class = mod_element['SampleClass'].get_object()
         var = sample_class['InnerClass'].get_object()
-        self.assertEquals(get_base_type('Type'), var.get_type())
+        self.assertEqual(get_base_type('Type'), var.get_type())
 
     @testutils.assert_raises(exceptions.ModuleNotFoundError)
     def test_non_existent_module(self):
         mod.write('import mod1\n')
         module = self.pycore.get_module('mod2')
         imported_sys = module['mod1'].get_object()
-        self.assertEquals(get_base_type('Module'), imported_sys.get_type())
+        self.assertEqual(get_base_type('Module'), imported_sys.get_type())
 
     def test_imported_as_names(self):
         testutils.create_module(self.project, 'mod1')
         mod.write('import mod1 as my_import\n')
         module = self.pycore.get_module('mod2')
         imported_mod = module['my_import'].get_object()
-        self.assertEquals(get_base_type('Module'), imported_mod.get_type())
+        self.assertEqual(get_base_type('Module'), imported_mod.get_type())
 
     def test_get_string_module(self):
         mod = self.pycore.get_string_module('class Sample(object):\n    pass\n')
         sample_class = mod['Sample'].get_object()
-        self.assertEquals(get_base_type('Type'), sample_class.get_type())
+        self.assertEqual(get_base_type('Type'), sample_class.get_type())
 
     def test_get_string_module_with_extra_spaces(self):
         mod = self.pycore.get_string_module('a = 10\n    ')
         code = 'def func(param1, param2=10, *param3, **param4):\n    pass'
         mod = self.pycore.get_string_module(code)
         sample_function = mod['func']
-        self.assertEquals(['param1', 'param2', 'param3', 'param4'],
+        self.assertEqual(['param1', 'param2', 'param3', 'param4'],
                           sample_function.get_object().get_param_names())
 
     # FIXME: Not found modules
     def xxx_test_not_found_module_is_module(self):
         mod = self.pycore.get_string_module('import doesnotexist\n')
-        self.assertEquals(get_base_type('Module'),
+        self.assertEqual(get_base_type('Module'),
                           mod['doesnotexist'].
                           get_object().get_type())
 
         mod = self.pycore.get_string_module(code)
         derived = mod['Derived'].get_object()
         self.assertTrue('method' in derived)
-        self.assertEquals(get_base_type('Function'),
+        self.assertEqual(get_base_type('Function'),
                           derived['method'].get_object().get_type())
 
     def test_inheriting_multiple_base_class_attributes(self):
         mod = self.pycore.get_string_module(code)
         base1 = mod['Base1'].get_object()
         derived = mod['Derived'].get_object()
-        self.assertEquals(base1['method'].get_object(),
+        self.assertEqual(base1['method'].get_object(),
                           derived['method'].get_object())
 
     def test_inheriting_unknown_base_class(self):
     def test_module_creation(self):
         new_module = testutils.create_module(self.project, 'module')
         self.assertFalse(new_module.is_folder())
-        self.assertEquals(self.project.get_resource('module.py'), new_module)
+        self.assertEqual(self.project.get_resource('module.py'), new_module)
 
     def test_packaged_module_creation(self):
         package = self.project.root.create_folder('package')
         new_module = testutils.create_module(self.project, 'package.module')
-        self.assertEquals(self.project.get_resource('package/module.py'), new_module)
+        self.assertEqual(self.project.get_resource('package/module.py'), new_module)
 
     def test_packaged_module_creation_with_nested_src(self):
         src = self.project.root.create_folder('src')
         package = src.create_folder('pkg')
         new_module = testutils.create_module(self.project, 'pkg.mod', src)
-        self.assertEquals(self.project.get_resource('src/pkg/mod.py'), new_module)
+        self.assertEqual(self.project.get_resource('src/pkg/mod.py'), new_module)
 
     def test_package_creation(self):
         new_package = testutils.create_package(self.project, 'pkg')
         self.assertTrue(new_package.is_folder())
-        self.assertEquals(self.project.get_resource('pkg'), new_package)
-        self.assertEquals(self.project.get_resource('pkg/__init__.py'),
+        self.assertEqual(self.project.get_resource('pkg'), new_package)
+        self.assertEqual(self.project.get_resource('pkg/__init__.py'),
                           new_package.get_child('__init__.py'));
 
     def test_nested_package_creation(self):
         package = testutils.create_package(self.project, 'pkg1')
         nested_package = testutils.create_package(self.project, 'pkg1.pkg2')
-        self.assertEquals(self.project.get_resource('pkg1/pkg2'), nested_package)
+        self.assertEqual(self.project.get_resource('pkg1/pkg2'), nested_package)
 
     def test_packaged_package_creation_with_nested_src(self):
         src = self.project.root.create_folder('src')
         package = testutils.create_package(self.project, 'pkg1', src)
         nested_package = testutils.create_package(self.project, 'pkg1.pkg2', src)
-        self.assertEquals(self.project.get_resource('src/pkg1/pkg2'), nested_package)
+        self.assertEqual(self.project.get_resource('src/pkg1/pkg2'), nested_package)
 
     def test_find_module(self):
         src = self.project.root.create_folder('src')
         samplemod = testutils.create_module(self.project, 'samplemod', src)
         found_module = self.pycore.find_module('samplemod')
-        self.assertEquals(samplemod, found_module)
+        self.assertEqual(samplemod, found_module)
 
     def test_find_nested_module(self):
         src = self.project.root.create_folder('src')
         samplepkg = testutils.create_package(self.project, 'samplepkg', src)
         samplemod = testutils.create_module(self.project, 'samplemod', samplepkg)
         found_module = self.pycore.find_module('samplepkg.samplemod')
-        self.assertEquals(samplemod, found_module)
+        self.assertEqual(samplemod, found_module)
 
     def test_find_multiple_module(self):
         src = self.project.root.create_folder('src')
         src = self.project.root
         samplepkg = testutils.create_package(self.project, 'samplepkg', src)
         found_module = self.pycore.find_module('samplepkg')
-        self.assertEquals(samplepkg, found_module)
+        self.assertEqual(samplepkg, found_module)
 
     def test_find_module_when_module_and_package_with_the_same_name(self):
         src = self.project.root
         samplemod = testutils.create_module(self.project, 'sample', src)
         samplepkg = testutils.create_package(self.project, 'sample', src)
         found_module = self.pycore.find_module('sample')
-        self.assertEquals(samplepkg, found_module)
+        self.assertEqual(samplepkg, found_module)
 
     def test_source_folders_preference(self):
         pkg1 = testutils.create_package(self.project, 'pkg1')
         self.assertEqual(self.project.pycore.find_module('lost'), lost)
 
     def test_getting_empty_source_folders(self):
-        self.assertEquals([], self.pycore.get_source_folders())
+        self.assertEqual([], self.pycore.get_source_folders())
 
     def test_root_source_folder(self):
         self.project.root.create_file('sample.py')
         source_folders = self.pycore.get_source_folders()
-        self.assertEquals(1, len(source_folders))
+        self.assertEqual(1, len(source_folders))
         self.assertTrue(self.project.root in source_folders)
 
     def test_root_source_folder2(self):
         self.project.root.create_file('mod1.py')
         self.project.root.create_file('mod2.py')
         source_folders = self.pycore.get_source_folders()
-        self.assertEquals(1, len(source_folders))
+        self.assertEqual(1, len(source_folders))
         self.assertTrue(self.project.root in source_folders)
 
     def test_src_source_folder(self):
         src = self.project.root.create_folder('src')
         src.create_file('sample.py')
         source_folders = self.pycore.get_source_folders()
-        self.assertEquals(1, len(source_folders))
+        self.assertEqual(1, len(source_folders))
         self.assertTrue(self.project.get_resource('src') in source_folders)
 
     def test_packages(self):
         pkg = src.create_folder('package')
         pkg.create_file('__init__.py')
         source_folders = self.pycore.get_source_folders()
-        self.assertEquals(1, len(source_folders))
+        self.assertEqual(1, len(source_folders))
         self.assertTrue(src in source_folders)
 
     def test_multi_source_folders(self):
         test = self.project.root.create_folder('test')
         test.create_file('alltests.py')
         source_folders = self.pycore.get_source_folders()
-        self.assertEquals(2, len(source_folders))
+        self.assertEqual(2, len(source_folders))
         self.assertTrue(src in source_folders)
         self.assertTrue(test in source_folders)
 
         package = testutils.create_package(self.project, 'package', src)
         mod2 = testutils.create_module(self.project, 'mod2', package)
         source_folders = self.pycore.get_source_folders()
-        self.assertEquals(2, len(source_folders))
+        self.assertEqual(2, len(source_folders))
         self.assertTrue(self.project.root in source_folders and \
                         src in source_folders)
 
     def test_get_pyname_definition_location(self):
         mod = self.pycore.get_string_module('a_var = 20\n')
         a_var = mod['a_var']
-        self.assertEquals((mod, 1), a_var.get_definition_location())
+        self.assertEqual((mod, 1), a_var.get_definition_location())
 
     def test_get_pyname_definition_location_functions(self):
         mod = self.pycore.get_string_module('def a_func():\n    pass\n')
         a_func = mod['a_func']
-        self.assertEquals((mod, 1), a_func.get_definition_location())
+        self.assertEqual((mod, 1), a_func.get_definition_location())
 
     def test_get_pyname_definition_location_class(self):
         code = 'class AClass(object):\n    pass\n\n'
         mod = self.pycore.get_string_module(code)
         a_class = mod['AClass']
-        self.assertEquals((mod, 1), a_class.get_definition_location())
+        self.assertEqual((mod, 1), a_class.get_definition_location())
 
     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['a_var']
-        self.assertEquals((mod, 2), a_var.get_definition_location())
+        self.assertEqual((mod, 2), a_var.get_definition_location())
 
     def test_get_pyname_definition_location_reassigning(self):
         mod = self.pycore.get_string_module('a_var = 20\na_var=30\n')
         a_var = mod['a_var']
-        self.assertEquals((mod, 1), a_var.get_definition_location())
+        self.assertEqual((mod, 1), a_var.get_definition_location())
 
     def test_get_pyname_definition_location_importes(self):
         module = testutils.create_module(self.project, 'mod')
         mod = self.pycore.get_string_module('import mod\n')
         imported_module = self.pycore.get_module('mod')
         module_pyname = mod['mod']
-        self.assertEquals((imported_module, 1),
+        self.assertEqual((imported_module, 1),
                           module_pyname.get_definition_location())
 
     def test_get_pyname_definition_location_imports(self):
         imported_module = self.pycore.get_module('mod')
         mod = self.pycore.get_string_module('from mod import a_func\n')
         a_func = mod['a_func']
-        self.assertEquals((imported_module, 2), a_func.get_definition_location())
+        self.assertEqual((imported_module, 2), a_func.get_definition_location())
 
     def test_get_pyname_definition_location_parameters(self):
         code = 'def a_func(param1, param2):\n    a_var = param\n'
         mod = self.pycore.get_string_module(code)
         a_func_scope = mod.get_scope().get_scopes()[0]
         param1 = a_func_scope['param1']
-        self.assertEquals((mod, 1), param1.get_definition_location())
+        self.assertEqual((mod, 1), param1.get_definition_location())
         param2 = a_func_scope['param2']
-        self.assertEquals((mod, 1), param2.get_definition_location())
+        self.assertEqual((mod, 1), param2.get_definition_location())
 
     def test_module_get_resource(self):
         module_resource = testutils.create_module(self.project, 'mod')
         module = self.pycore.get_module('mod')
-        self.assertEquals(module_resource, module.get_resource())
+        self.assertEqual(module_resource, module.get_resource())
         string_module = self.pycore.get_string_module('from mod import a_func\n')
-        self.assertEquals(None, string_module.get_resource())
+        self.assertEqual(None, string_module.get_resource())
 
     def test_get_pyname_definition_location_class2(self):
         code = 'class AClass(object):\n' \
         mod = self.pycore.get_string_module(code)
         a_class = mod['AClass'].get_object()
         an_attr = a_class['an_attr']
-        self.assertEquals((mod, 3), an_attr.get_definition_location())
+        self.assertEqual((mod, 3), an_attr.get_definition_location())
 
     def test_import_not_found_module_get_definition_location(self):
         mod = self.pycore.get_string_module('import doesnotexist\n')
         does_not_exist = mod['doesnotexist']
-        self.assertEquals((None, None), does_not_exist.get_definition_location())
+        self.assertEqual((None, None), does_not_exist.get_definition_location())
 
     def test_from_not_found_module_get_definition_location(self):
         mod = self.pycore.get_string_module('from doesnotexist import Sample\n')
         sample = mod['Sample']
-        self.assertEquals((None, None), sample.get_definition_location())
+        self.assertEqual((None, None), sample.get_definition_location())
 
     def test_from_package_import_module_get_definition_location(self):
         pkg = testutils.create_package(self.project, 'pkg')
         pkg_mod = self.pycore.get_module('pkg.mod')
         mod = self.pycore.get_string_module('from pkg import mod\n')
         imported_mod = mod['mod']
-        self.assertEquals((pkg_mod, 1),
+        self.assertEqual((pkg_mod, 1),
                           imported_mod.get_definition_location())
 
     def test_get_module_for_defined_pyobjects(self):
         mod = self.pycore.get_string_module('class AClass(object):\n    pass\n')
         a_class = mod['AClass'].get_object()
-        self.assertEquals(mod, a_class.get_module())
+        self.assertEqual(mod, a_class.get_module())
 
     def test_get_definition_location_for_packages(self):
         pkg = testutils.create_package(self.project, 'pkg')
         init_module = self.pycore.get_module('pkg.__init__')
         mod = self.pycore.get_string_module('import pkg\n')
         pkg_pyname = mod['pkg']
-        self.assertEquals((init_module, 1), pkg_pyname.get_definition_location())
+        self.assertEqual((init_module, 1), pkg_pyname.get_definition_location())
 
     def test_get_definition_location_for_filtered_packages(self):
         pkg = testutils.create_package(self.project, 'pkg')
         init_module = self.pycore.get_module('pkg.__init__')
         mod = self.pycore.get_string_module('import pkg.mod')
         pkg_pyname = mod['pkg']
-        self.assertEquals((init_module, 1), pkg_pyname.get_definition_location())
+        self.assertEqual((init_module, 1), pkg_pyname.get_definition_location())
 
     def test_out_of_project_modules(self):
         scope = self.pycore.get_string_scope('import rope.base.project as project\n')
         global_var = mod['a_var']
         func_scope = mod['a_func'].get_object().get_scope()
         local_var = func_scope['a_var']
-        self.assertEquals(global_var, local_var)
+        self.assertEqual(global_var, local_var)
 
     def test_not_leaking_for_vars_inside_parent_scope(self):
         mod = testutils.create_module(self.project, 'mod')
         pymod = self.pycore.get_string_module(code)
         a_class = pymod['A'].get_object()
         var = pymod['var'].get_object()
-        self.assertEquals(a_class, var.get_type())
+        self.assertEqual(a_class, var.get_type())
 
     @testutils.run_only_for_25
     def test_with_statement_with_no_vars(self):
                '    myvar = 1\n'
         mod = self.pycore.get_string_module(code)
         a_var = mod['myvar']
-        self.assertEquals((mod, 4), a_var.get_definition_location())
+        self.assertEqual((mod, 4), a_var.get_definition_location())
 
     def test_check_names_defined_in_whiles(self):
         mod = self.pycore.get_string_module('while False:\n    myvar = 1\n')
         a_var = mod['myvar']
-        self.assertEquals((mod, 2), a_var.get_definition_location())
+        self.assertEqual((mod, 2), a_var.get_definition_location())
 
     def test_get_definition_location_in_tuple_assnames(self):
         mod = self.pycore.get_string_module(
             'def f(x):\n    x.z, a = range(2)\n')
         x = mod['f'].get_object().get_scope()['x']
         a = mod['f'].get_object().get_scope()['a']
-        self.assertEquals((mod, 1), x.get_definition_location())
-        self.assertEquals((mod, 2), a.get_definition_location())
+        self.assertEqual((mod, 1), x.get_definition_location())
+        self.assertEqual((mod, 2), a.get_definition_location())
 
     @testutils.assert_raises(exceptions.ModuleSyntaxError)
     def test_syntax_errors_in_code(self):
         try:
             mod = self.pycore.get_string_module('xyx print\n')
         except exceptions.ModuleSyntaxError as e:
-            self.assertEquals(1, e.lineno)
+            self.assertEqual(1, e.lineno)
 
     def test_no_exceptions_on_module_encoding_problems(self):
         mod = testutils.create_module(self.project, 'mod')
         mod1 = testutils.create_module(self.project, 'mod1')
         mod1.write('var1 = ""\nvar2 = ""\n')
         pymod1 = self.pycore.resource_to_pyobject(mod1)
-        self.assertEquals(pymod1['var1'].get_object(),
+        self.assertEqual(pymod1['var1'].get_object(),
                           pymod1['var2'].get_object())
 
 
     def test_simple_import(self):
         mod = self.pycore.get_string_module('import samplemod\n')
         samplemod = mod['samplemod'].get_object()
-        self.assertEquals(get_base_type('Module'), samplemod.get_type())
+        self.assertEqual(get_base_type('Module'), samplemod.get_type())
 
     def test_from_import_class(self):
         mod = self.pycore.get_string_module('from samplemod import SampleClass\n')
         result = mod['SampleClass'].get_object()
-        self.assertEquals(get_base_type('Type'), result.get_type())
+        self.assertEqual(get_base_type('Type'), result.get_type())
         self.assertTrue('sample_func' not in mod.get_attributes())
 
     def test_from_import_star(self):
         mod = self.pycore.get_string_module('from samplemod import *\n')
-        self.assertEquals(get_base_type('Type'),
+        self.assertEqual(get_base_type('Type'),
                           mod['SampleClass'].get_object().get_type())
-        self.assertEquals(get_base_type('Function'),
+        self.assertEqual(get_base_type('Function'),
                           mod['sample_func'].get_object().get_type())
         self.assertTrue(mod['sample_var'] is not None)
 
         mod = self.pycore.get_string_module(code)
         samplemod = self.pycore.get_module('samplemod')
         sample_class = samplemod['SampleClass'].get_object()
-        self.assertNotEquals(sample_class,
+        self.assertNotEqual(sample_class,
                              mod.get_attributes()['SampleClass'].get_object())
 
     def test_from_import_star_not_imporing_underlined(self):
 
     def test_from_package_import_mod(self):
         mod = self.pycore.get_string_module('from package import nestedmod\n')
-        self.assertEquals(get_base_type('Module'),
+        self.assertEqual(get_base_type('Module'),
                           mod['nestedmod'].get_object().get_type())
 
     # XXX: Deciding to import everything on import start from packages
     def test_from_import_function(self):
         code = 'def f():\n    from samplemod import SampleClass\n'
         scope = self.pycore.get_string_scope(code)
-        self.assertEquals(get_base_type('Type'),
+        self.assertEqual(get_base_type('Type'),
                           scope.get_scopes()[0]['SampleClass'].
                           get_object().get_type())
 
         mod2 = testutils.create_module(self.project, 'mod2', pkg)
         mod = self.pycore.get_string_module('import pkg.mod1\nimport pkg.mod2\n')
         package = mod['pkg'].get_object()
-        self.assertEquals(2, len(package.get_attributes()))
+        self.assertEqual(2, len(package.get_attributes()))
         self.assertTrue('mod1' in package and
                         'mod2' in package)
 
         mod = self.pycore.get_string_module(code)
         package1 = mod['pkg1'].get_object()
         package2 = package1['pkg2'].get_object()
-        self.assertEquals(2, len(package2.get_attributes()))
+        self.assertEqual(2, len(package2.get_attributes()))
         self.assertTrue('mod1' in package2 and 'mod2' in package2)
 
     def test_multi_dot_imports_as(self):
         module = testutils.create_module(self.project, 'mod', pkg2)
         mod = self.pycore.get_string_module('from pkg1 import pkg2\n')
         package = mod['pkg2']
-        self.assertEquals(0, len(package.get_attributes()))
+        self.assertEqual(0, len(package.get_attributes()))
 
     def test_invalidating_cache_after_resource_change(self):
         module = testutils.create_module(self.project, 'mod')
         code = 'from doesnotexistmod import DoesNotExistClass\n'
         mod = self.pycore.get_string_module(code)
         self.assertTrue('DoesNotExistClass' in mod)
-        self.assertEquals(get_base_type('Unknown'),
+        self.assertEqual(get_base_type('Unknown'),
                           mod['DoesNotExistClass'].
                           get_object().get_type())
 
         code = 'from samplemod import DoesNotExistClass\n'
         mod = self.pycore.get_string_module(code)
         self.assertTrue('DoesNotExistClass' in mod)
-        self.assertEquals(get_base_type('Unknown'),
+        self.assertEqual(get_base_type('Unknown'),
                           mod['DoesNotExistClass'].
                           get_object().get_type())
 
     def test_not_considering_imported_names_as_sub_scopes(self):
         code = 'from samplemod import SampleClass\n'
         scope = self.pycore.get_string_scope(code)
-        self.assertEquals(0, len(scope.get_scopes()))
+        self.assertEqual(0, len(scope.get_scopes()))
 
     def test_not_considering_imported_modules_as_sub_scopes(self):
         scope = self.pycore.get_string_scope('import samplemod\n')
-        self.assertEquals(0, len(scope.get_scopes()))
+        self.assertEqual(0, len(scope.get_scopes()))
 
     def test_inheriting_dotted_base_class(self):
         code = 'import samplemod\n' \
         scope = self.pycore.get_string_scope(code)
         sample_class = scope['Sample'].get_object()
         func_scope = scope.get_scopes()[0].get_scopes()[0]
-        self.assertEquals(sample_class,
+        self.assertEqual(sample_class,
                           func_scope['self'].get_object().get_type())
         self.assertTrue('func' in func_scope['self'].
                                 get_object())
         scope = self.pycore.get_string_scope(code)
         sample_class = scope['Sample'].get_object()
         func_scope = scope.get_scopes()[0].get_scopes()[0]
-        self.assertNotEquals(sample_class,
+        self.assertNotEqual(sample_class,
                              func_scope['self'].get_object().get_type())
 
     def test_location_of_imports_when_importing(self):
         scope = self.pycore.get_string_scope('from mod import SampleClass\n')
         sample_class = scope['SampleClass']
         samplemod = self.pycore.get_module('samplemod')
-        self.assertEquals((samplemod, 1), sample_class.get_definition_location())
+        self.assertEqual((samplemod, 1), sample_class.get_definition_location())
 
     def test_nested_modules(self):
         pkg = testutils.create_package(self.project, 'pkg')
         imported_module = self.pycore.get_module('pkg.mod')
         scope = self.pycore.get_string_scope('import pkg.mod\n')
         mod_pyobject = scope['pkg'].get_object()['mod']
-        self.assertEquals((imported_module, 1),
+        self.assertEqual((imported_module, 1),
                           mod_pyobject.get_definition_location())
 
     def test_reading_init_dot_py(self):
         mod2.write('import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(mod1_object, mod2_object.get_attributes()['mod1'].get_object())
+        self.assertEqual(mod1_object, mod2_object.get_attributes()['mod1'].get_object())
 
     def test_relative_froms(self):
         pkg = testutils.create_package(self.project, 'pkg')
         mod2.write('from mod1 import a_func\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(mod1_object['a_func'].get_object(),
+        self.assertEqual(mod1_object['a_func'].get_object(),
                           mod2_object['a_func'].get_object())
 
     def test_relative_imports_for_string_modules(self):
         mod2.write('import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.get_string_module(mod2.read(), mod2)
-        self.assertEquals(mod1_object, mod2_object['mod1'].get_object())
+        self.assertEqual(mod1_object, mod2_object['mod1'].get_object())
 
     def test_relative_imports_for_string_scopes(self):
         pkg = testutils.create_package(self.project, 'pkg')
         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['mod1'].get_object())
+        self.assertEqual(mod1_object, mod2_scope['mod1'].get_object())
 
     @testutils.run_only_for_25
     def test_new_style_relative_imports(self):
         mod2.write('from . import mod1\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(mod1_object, mod2_object['mod1'].get_object())
+        self.assertEqual(mod1_object, mod2_object['mod1'].get_object())
 
     @testutils.run_only_for_25
     def test_new_style_relative_imports2(self):
         mod2.write('from ..mod1 import a_func\n')
         mod1_object = self.pycore.resource_to_pyobject(mod1)
         mod2_object = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(mod1_object['a_func'].get_object(),
+        self.assertEqual(mod1_object['a_func'].get_object(),
                           mod2_object['a_func'].get_object())
 
     def test_invalidating_cache_for_from_imports_after_resource_change(self):
 
         pymod1 = self.pycore.get_module('mod1')
         pymod2 = self.pycore.get_module('mod2')
-        self.assertEquals(pymod1['a_func'].get_object(),
+        self.assertEqual(pymod1['a_func'].get_object(),
                           pymod2['a_func'].get_object())
         mod2.write(mod2.read() + '\n')
         pymod2 = self.pycore.get_module('mod2')
-        self.assertEquals(pymod1['a_func'].get_object(),
+        self.assertEqual(pymod1['a_func'].get_object(),
                           pymod2['a_func'].get_object())
 
     def test_invalidating_superclasses_after_change(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.