1. zjes
  2. rope_py3k

Source

rope_py3k / ropetest / advanced_oi_test.py

Diff from to

File ropetest/advanced_oi_test.py

  • Ignore whitespace
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod['a_func'].get_object(),
+        self.assertEqual(pymod['a_func'].get_object(),
                           pymod['a_var'].get_object())
 
     def test_module_dti(self):
         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),
+        self.assertEqual(self.pycore.resource_to_pyobject(mod1),
                           pymod2['a_var'].get_object())
 
     def test_class_from_another_module_dti(self):
         self.pycore.run_module(mod2).wait_process()
         pymod1 = self.pycore.resource_to_pyobject(mod1)
         pymod2 = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(pymod2['AClass'].get_object(),
+        self.assertEqual(pymod2['AClass'].get_object(),
                           pymod2['a_var'].get_object())
 
 
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod['AClass'].get_object(),
+        self.assertEqual(pymod['AClass'].get_object(),
                           pymod['a_var'].get_object())
 
     def test_instance_dti(self):
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod['AClass'].get_object(),
+        self.assertEqual(pymod['AClass'].get_object(),
                           pymod['a_var'].get_object().get_type())
 
     def test_method_dti(self):
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod['AClass'].get_object(),
+        self.assertEqual(pymod['AClass'].get_object(),
                           pymod['a_var'].get_object().get_type())
 
     def test_function_argument_dti(self):
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
-        self.assertEquals(pyscope['a_func'].get_object(),
+        self.assertEqual(pyscope['a_func'].get_object(),
                           pyscope.get_scopes()[0]['arg'].get_object())
 
     def test_classes_with_the_same_name(self):
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertEquals(pymod['AClass'].get_object(),
+        self.assertEqual(pymod['AClass'].get_object(),
                           pymod['a_var'].get_object())
 
     def test_nested_classes(self):
         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]['AClass'].get_object(),
+        self.assertEqual(pyscope.get_scopes()[0]['AClass'].get_object(),
                           pyscope['a_var'].get_object())
 
     def test_function_argument_dti2(self):
         mod.write(code)
         self.pycore.run_module(mod).wait_process()
         pyscope = self.pycore.resource_to_pyobject(mod).get_scope()
-        self.assertEquals(pyscope['a_func'].get_object(),
+        self.assertEqual(pyscope['a_func'].get_object(),
                           pyscope.get_scopes()[0]['arg'].get_object())
 
     def test_dti_and_concluded_data_invalidation(self):
         pymod = self.pycore.resource_to_pyobject(mod)
         pymod['a_var'].get_object()
         self.pycore.run_module(mod).wait_process()
-        self.assertEquals(pymod['a_func'].get_object(),
+        self.assertEqual(pymod['a_func'].get_object(),
                           pymod['a_var'].get_object())
 
     def test_list_objects_and_dynamicoi(self):
         pymod = self.pycore.resource_to_pyobject(mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_for_loops_and_dynamicoi(self):
         mod = testutils.create_module(self.project, 'mod')
         pymod = self.pycore.resource_to_pyobject(mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_dict_objects_and_dynamicoi(self):
         mod = testutils.create_module(self.project, 'mod')
         pymod = self.pycore.resource_to_pyobject(mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_dict_keys_and_dynamicoi(self):
         mod = testutils.create_module(self.project, 'mod')
         pymod = self.pycore.resource_to_pyobject(mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_dict_keys_and_dynamicoi2(self):
         mod = testutils.create_module(self.project, 'mod')
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_strs_and_dynamicoi(self):
         mod = testutils.create_module(self.project, 'mod')
                 to_pyobject.transform(to_textual.transform(pyobject)))
         for name in ('C', 'f', 'a_var', 'a_list', 'a_str', 'a_file'):
             var = pymod[name].get_object()
-            self.assertEquals(to_textual.transform(var), complex_to_textual(var))
-        self.assertEquals(to_textual.transform(pymod), complex_to_textual(pymod))
+            self.assertEqual(to_textual.transform(var), complex_to_textual(var))
+        self.assertEqual(to_textual.transform(pymod), complex_to_textual(pymod))
         enumerate_func = rope.base.builtins.builtins['enumerate'].get_object()
-        self.assertEquals(to_textual.transform(enumerate_func),
+        self.assertEqual(to_textual.transform(enumerate_func),
                           complex_to_textual(enumerate_func))
 
     def test_arguments_with_keywords(self):
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_a_function_with_different_returns(self):
         mod = testutils.create_module(self.project, 'mod')
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_a_function_with_different_returns2(self):
         mod = testutils.create_module(self.project, 'mod')
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_ignoring_star_args(self):
         mod = testutils.create_module(self.project, 'mod')
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_ignoring_double_star_args(self):
         mod = testutils.create_module(self.project, 'mod')
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_invalidating_data_after_changing(self):
         mod = testutils.create_module(self.project, 'mod')
         mod.write(code.replace('a_func', 'newfunc'))
         mod.write(code)
         pymod = self.pycore.resource_to_pyobject(mod)
-        self.assertNotEquals(pymod['a_func'].get_object(),
+        self.assertNotEqual(pymod['a_func'].get_object(),
                              pymod['a_var'].get_object())
 
     def test_invalidating_data_after_moving(self):
         mod.move('newmod.py')
         pymod = self.pycore.get_module('newmod')
         pymod2 = self.pycore.resource_to_pyobject(mod2)
-        self.assertEquals(pymod2['C'].get_object(),
+        self.assertEqual(pymod2['C'].get_object(),
                           pymod['a_var'].get_object())
 
 
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
         p_type = f_scope['p'].get_object().get_type()
-        self.assertEquals(c_class, p_type)
+        self.assertEqual(c_class, p_type)
 
     def test_static_oi_not_failing_when_callin_callables(self):
         code = 'class C(object):\n    pass\nC()\n'
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
         p_type = f_scope['p'].get_object().get_type()
-        self.assertEquals(c_class, p_type)
+        self.assertEqual(c_class, p_type)
 
     def test_static_oi_class_methods(self):
         code = 'class C(object):\n    def f(self, p):\n        pass\n' \
         c_class = pymod['C'].get_object()
         f_scope = c_class['f'].get_object().get_scope()
         p_type = f_scope['p'].get_object().get_type()
-        self.assertEquals(c_class, p_type)
+        self.assertEqual(c_class, p_type)
 
     def test_static_oi_preventing_soi_maximum_recursion_exceptions(self):
         code = 'item = {}\nfor item in item.keys():\n    pass\n'
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(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' \
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(c2_class, b_var.get_type())
 
     def test_not_reporting_out_of_date_information(self):
         code = 'class C1(object):\n    pass\n' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c1_class = pymod['C1'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
 
         self.mod.write(code.replace('C1', 'C2'))
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c2_class, a_var.get_type())
+        self.assertEqual(c2_class, a_var.get_type())
 
     def test_invalidating_concluded_data_in_a_function(self):
         mod1 = testutils.create_module(self.project, 'mod1')
         pymod2 = self.pycore.resource_to_pyobject(mod2)
         c1_class = pymod2['C1'].get_object()
         a_var = pymod2['a_var'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEqual(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['C2'].get_object()
         a_var = pymod2['a_var'].get_object()
-        self.assertEquals(c2_class, a_var.get_type())
+        self.assertEqual(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'
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(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):
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(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' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_static_oi_for_lists_per_object_for_fields(self):
         code = 'class C(object):\n    pass\n' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(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' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(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' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_static_oi_for_lists_per_object_for_iters(self):
         code = 'class C(object):\n    pass\n' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(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' \
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(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' \
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(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' \
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(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' \
         c2_class = pymod['C2'].get_object()
         a_var = pymod['a'].get_object()
         b_var = pymod['b'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
-        self.assertEquals(c2_class, b_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
+        self.assertEqual(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' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c_class, a_var.get_type())
+        self.assertEqual(c_class, a_var.get_type())
 
     def test_properties_and_calling_get_property(self):
         code = 'class C1(object):\n    pass\n' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c1_class = pymod['C1'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
 
     def test_soi_on_constructors(self):
         code = 'class C1(object):\n    pass\n' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c1_class = pymod['C1'].get_object()
         a_var = pymod['a_var'].get_object()
-        self.assertEquals(c1_class, a_var.get_type())
+        self.assertEqual(c1_class, a_var.get_type())
 
     def test_not_saving_unknown_function_returns(self):
         mod2 = testutils.create_module(self.project, 'mod2')
         a_var = pymod2['a_var']
 
         self.pycore.analyze_module(mod2)
-        self.assertNotEquals(c_class, a_var.get_object().get_type())
+        self.assertNotEqual(c_class, a_var.get_object().get_type())
 
         self.pycore.analyze_module(self.mod)
-        self.assertEquals(c_class, a_var.get_object().get_type())
+        self.assertEqual(c_class, a_var.get_object().get_type())
 
     def test_using_the_best_callinfo(self):
         code = 'class C1(object):\n    pass\n' \
         c1_class = pymod['C1'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
         arg2 = f_scope['arg2'].get_object()
-        self.assertEquals(c1_class, arg2.get_type())
+        self.assertEqual(c1_class, arg2.get_type())
 
     def test_call_function_and_parameters(self):
         code = 'class A(object):\n    def __call__(self, p):\n        pass\n' \
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
         p_type = f_scope['p'].get_object().get_type()
-        self.assertEquals(c_class, p_type)
+        self.assertEqual(c_class, p_type)
 
     def test_report_libutils_and_analyze_all_modules(self):
         code = 'class C(object):\n    pass\ndef f(p):\n    pass\nf(C())\n'
         c_class = pymod['C'].get_object()
         f_scope = pymod['f'].get_object().get_scope()
         p_type = f_scope['p'].get_object().get_type()
-        self.assertEquals(c_class, p_type)
+        self.assertEqual(c_class, p_type)
 
     def test_validation_problems_for_objectdb_retrievals(self):
         mod1 = testutils.create_module(self.project, 'mod1')
         c_class = pymod2['C'].get_object()
         pymod1 = self.pycore.resource_to_pyobject(mod1)
         var_pyname = pymod1['var']
-        self.assertEquals(c_class, var_pyname.get_object().get_type())
+        self.assertEqual(c_class, var_pyname.get_object().get_type())
         mod2.write('import mod1\n\nmod1.l.append("")\n')
-        self.assertNotEquals(c_class, var_pyname.get_object().get_type(),
+        self.assertNotEqual(c_class, var_pyname.get_object().get_type(),
                              'Class `C` no more exists')
 
     def test_validation_problems_for_changing_builtin_types(self):
         a_class = pymod['A'].get_object()
         f_scope = a_class.get_scope().get_scopes()[0]
         p_type = f_scope['p'].get_object().get_type()
-        self.assertEquals(a_class, p_type)
+        self.assertEqual(a_class, p_type)
 
     def test_following_function_calls_when_asked_to(self):
         code = 'class A(object):\n    pass\n' \
         pymod = self.pycore.resource_to_pyobject(self.mod)
         a_class = pymod['A'].get_object()
         x_var = pymod['x'].get_object().get_type()
-        self.assertEquals(a_class, x_var)
+        self.assertEqual(a_class, x_var)
 
 
 def suite():