diff --git a/pylasu/testing/testing.py b/pylasu/testing/testing.py index 6c43916..a20edc3 100644 --- a/pylasu/testing/testing.py +++ b/pylasu/testing/testing.py @@ -56,11 +56,11 @@ def assert_single_properties_are_equal(case, expected_property, expected_prop_va def assert_multi_properties_are_equal(case, expected_property, expected_prop_value, actual_prop_value, context, consider_position): # TODO IgnoreChildren - case.assertEquals(actual_prop_value is None, expected_prop_value is None, - f"{context}.{expected_property.name} nullness") + case.assertEqual(actual_prop_value is None, expected_prop_value is None, + f"{context}.{expected_property.name} nullness") if actual_prop_value is not None and expected_prop_value is not None: - case.assertEquals(len(actual_prop_value), len(expected_prop_value), - f"{context}.{expected_property.name} length") + case.assertEqual(len(actual_prop_value), len(expected_prop_value), + f"{context}.{expected_property.name} length") for expected_it, actual_it, i in \ zip(expected_prop_value, actual_prop_value, range(len(expected_prop_value))): assert_asts_are_equal(case, expected_it, actual_it, f"{context}[{i}]", diff --git a/tests/mapping/test_parse_tree_to_ast_transformers.py b/tests/mapping/test_parse_tree_to_ast_transformers.py index f9a0fe2..42e7c55 100644 --- a/tests/mapping/test_parse_tree_to_ast_transformers.py +++ b/tests/mapping/test_parse_tree_to_ast_transformers.py @@ -59,7 +59,7 @@ def test_simple_entities_transformer(self): entity BAR { } } """)) - self.assertEquals(expected_ast, actual_ast) + self.assertEqual(expected_ast, actual_ast) def test_entities_with_features_transformer(self): transformer = ParseTreeToASTTransformer(allow_generic_node=False) @@ -99,7 +99,7 @@ def test_entities_with_features_transformer(self): C: FOO; } }""")) - self.assertEquals(expected_ast, actual_ast) + self.assertEqual(expected_ast, actual_ast) def parse_entities(self, code: str) -> AntlrEntityParser.ModuleContext: lexer = AntlrEntityLexer(InputStream(code)) diff --git a/tests/test_metamodel_builder.py b/tests/test_metamodel_builder.py index 4707033..6512251 100644 --- a/tests/test_metamodel_builder.py +++ b/tests/test_metamodel_builder.py @@ -43,7 +43,7 @@ def open_out_stream(self, other=None): resource.append(eClass) with BytesIO() as out: resource.save(out) - self.assertEquals( + self.assertEqual( json.loads('''{ "eClass": "http://www.eclipse.org/emf/2002/Ecore#//EPackage", "nsPrefix": "test", @@ -101,24 +101,24 @@ def test_build_metamodel_single_package(self): mb = MetamodelBuilder("tests.fixtures", "https://strumenta.com/pylasu/test/fixtures") box = mb.provide_class(Box) self.assertIsInstance(box(), EObject) - self.assertEquals(box.eClass.ePackage, mb.package) + self.assertEqual(box.eClass.ePackage, mb.package) self.assertTrue(box.eClass in mb.package.eContents) self.assertIsNotNone( next((a for a in box.eClass.eAllAttributes() if a.name == "name"), None)) - self.assertEquals(1, len(box.eClass.eAllAttributes())) + self.assertEqual(1, len(box.eClass.eAllAttributes())) def test_build_metamodel_single_package_inheritance(self): mb = MetamodelBuilder("tests.fixtures", "https://strumenta.com/pylasu/test/fixtures") box = mb.provide_class(ReinforcedBox) self.assertIsInstance(box(), EObject) - self.assertEquals(box.eClass.ePackage, mb.package) - self.assertEquals(2, len(mb.package.eContents)) + self.assertEqual(box.eClass.ePackage, mb.package) + self.assertEqual(2, len(mb.package.eContents)) self.assertTrue(box.eClass in mb.package.eContents) self.assertIsNotNone( next((a for a in box.eClass.eAllAttributes() if a.name == "name"), None)) self.assertIsNotNone( next((a for a in box.eClass.eAllAttributes() if a.name == "strength"), None)) - self.assertEquals(2, len(box.eClass.eAllAttributes())) + self.assertEqual(2, len(box.eClass.eAllAttributes())) STARLASU_MODEL_JSON = '''{ diff --git a/tests/test_model.py b/tests/test_model.py index 7fc223c..542071b 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -33,11 +33,11 @@ class ModelTest(unittest.TestCase): def test_reference_by_name_unsolved_str(self): ref_unsolved = ReferenceByName[SomeNode]("foo") - self.assertEquals("Ref(foo)[Unsolved]", str(ref_unsolved)) + self.assertEqual("Ref(foo)[Unsolved]", str(ref_unsolved)) def test_reference_by_name_solved_str(self): ref_solved = ReferenceByName[SomeNode]("foo", SomeNode(name="foo")) - self.assertEquals("Ref(foo)[Solved]", str(ref_solved)) + self.assertEqual("Ref(foo)[Solved]", str(ref_solved)) def test_try_to_resolve_positive_case_same_case(self): ref = ReferenceByName[SomeNode]("foo") @@ -61,9 +61,9 @@ def test_empty_node(self): def test_node_with_position(self): node = Node().with_position(Position(Point(1, 0), Point(2, 1))) - self.assertEquals(Position(Point(1, 0), Point(2, 1)), node.position) + self.assertEqual(Position(Point(1, 0), Point(2, 1)), node.position) node = SomeNode("").with_position(Position(Point(1, 0), Point(2, 1))) - self.assertEquals(Position(Point(1, 0), Point(2, 1)), node.position) + self.assertEqual(Position(Point(1, 0), Point(2, 1)), node.position) def test_node_properties(self): node = SomeNode("n").with_position(Position(Point(1, 0), Point(2, 1))) @@ -84,7 +84,7 @@ def test_scope_lookup_0(self): local_symbol = SomeSymbol(name='a', index=0) scope = Scope(symbols={'a': [local_symbol]}, parent=Scope(symbols={'a': [SomeSymbol(name='a', index=1)]})) result = scope.lookup(symbol_name='a') - self.assertEquals(result, local_symbol) + self.assertEqual(result, local_symbol) self.assertIsInstance(result, Symbol) def test_scope_lookup_1(self): @@ -92,7 +92,7 @@ def test_scope_lookup_1(self): upper_symbol = SomeSymbol(name='a', index=0) scope = Scope(symbols={'b': [SomeSymbol(name='b', index=0)]}, parent=Scope(symbols={'a': [upper_symbol]})) result = scope.lookup(symbol_name='a') - self.assertEquals(result, upper_symbol) + self.assertEqual(result, upper_symbol) self.assertIsInstance(result, Symbol) def test_scope_lookup_2(self): @@ -111,7 +111,7 @@ def test_scope_lookup_4(self): upper_symbol = SomeSymbol(name='a', index=0) scope = Scope(symbols={'b': [SomeSymbol(name='b', index=0)]}, parent=Scope(symbols={'a': [upper_symbol]})) result = scope.lookup(symbol_name='a', symbol_type=SomeSymbol) - self.assertEquals(result, upper_symbol) + self.assertEqual(result, upper_symbol) self.assertIsInstance(result, SomeSymbol) def test_scope_lookup_5(self): @@ -119,7 +119,7 @@ def test_scope_lookup_5(self): upper_symbol = SomeSymbol(name='a', index=0) scope = Scope(symbols={'a': [AnotherSymbol(name='a', index=0)]}, parent=Scope(symbols={'a': [upper_symbol]})) result = scope.lookup(symbol_name='a', symbol_type=SomeSymbol) - self.assertEquals(result, upper_symbol) + self.assertEqual(result, upper_symbol) self.assertIsInstance(result, SomeSymbol) def test_scope_lookup_6(self): @@ -138,15 +138,15 @@ def test_scope_lookup_7(self): def test_node_properties_meta(self): pds = [pd for pd in sorted(SomeNode.node_properties, key=lambda x: x.name)] - self.assertEquals(5, len(pds)) - self.assertEquals("bar", pds[0].name) + self.assertEqual(5, len(pds)) + self.assertEqual("bar", pds[0].name) self.assertFalse(pds[0].provides_nodes) - self.assertEquals("foo", pds[1].name) + self.assertEqual("foo", pds[1].name) self.assertFalse(pds[1].provides_nodes) - self.assertEquals("multiple", pds[2].name) + self.assertEqual("multiple", pds[2].name) self.assertTrue(pds[2].provides_nodes) - self.assertEquals(Multiplicity.MANY, pds[2].multiplicity) - self.assertEquals("name", pds[3].name) + self.assertEqual(Multiplicity.MANY, pds[2].multiplicity) + self.assertEqual("name", pds[3].name) self.assertFalse(pds[3].provides_nodes) - self.assertEquals("ref", pds[4].name) + self.assertEqual("ref", pds[4].name) self.assertTrue(pds[4].provides_nodes) diff --git a/tests/test_parse_tree.py b/tests/test_parse_tree.py index 88fa796..ba3f592 100644 --- a/tests/test_parse_tree.py +++ b/tests/test_parse_tree.py @@ -16,8 +16,8 @@ def test_parse_tree_origin(self): origin = ParseTreeOrigin(parse_tree) position = origin.position self.assertIsNotNone(position) - self.assertEquals(position.start, Point(1, 0)) - self.assertEquals(position.end, Point(2, 2)) + self.assertEqual(position.start, Point(1, 0)) + self.assertEqual(position.end, Point(2, 2)) def test_ast_gen(self): generate_nodes_classes_for_parser(SimpleLangParser, globals()) diff --git a/tests/test_processing.py b/tests/test_processing.py index 739304a..50cf6c8 100644 --- a/tests/test_processing.py +++ b/tests/test_processing.py @@ -25,8 +25,8 @@ class CW(Node): class ProcessingTest(unittest.TestCase): def test_search_by_type(self): - self.assertEquals(["1", "2", "3", "4", "5", "6"], [i.name for i in box.search_by_type(Item)]) - self.assertEquals( + self.assertEqual(["1", "2", "3", "4", "5", "6"], [i.name for i in box.search_by_type(Item)]) + self.assertEqual( ["root", "first", "1", "2", "big", "small", "3", "4", "5", "6"], [n.name for n in box.search_by_type(Node)] ) @@ -39,8 +39,8 @@ def test_replace_in_list(self): b = BW(a1, [a2, a3]) b.assign_parents() a2.replace_with(a4) - self.assertEquals("4", b.many_as[0].s) - self.assertEquals(BW(a1, [a4, a3]), b) + self.assertEqual("4", b.many_as[0].s) + self.assertEqual(BW(a1, [a4, a3]), b) def test_replace_in_set(self): a1 = AW("1") @@ -57,4 +57,4 @@ def test_replace_single(self): b = BW(a1, []) b.assign_parents() a1.replace_with(a2) - self.assertEquals("2", b.a.s) + self.assertEqual("2", b.a.s) diff --git a/tests/test_transpilation_trace.py b/tests/test_transpilation_trace.py index e0f6798..a04dabc 100644 --- a/tests/test_transpilation_trace.py +++ b/tests/test_transpilation_trace.py @@ -38,13 +38,13 @@ def test_serialize_transpilation_issue(self): message="some issue", severity=starlasu.IssueSeverity.getEEnumLiteral("WARNING"))] ) - self.assertEquals("a:1", tt.originalCode) - self.assertEquals("b:2", tt.generatedCode) - self.assertEquals("some issue", tt.issues[0].message) - self.assertEquals("a", tt.sourceResult.root.name) - self.assertEquals(1, tt.sourceResult.root.value) - self.assertEquals("b", tt.targetResult.root.name) - self.assertEquals(2, tt.targetResult.root.value) + self.assertEqual("a:1", tt.originalCode) + self.assertEqual("b:2", tt.generatedCode) + self.assertEqual("some issue", tt.issues[0].message) + self.assertEqual("a", tt.sourceResult.root.name) + self.assertEqual(1, tt.sourceResult.root.value) + self.assertEqual("b", tt.targetResult.root.name) + self.assertEqual(2, tt.targetResult.root.value) expected = """{ "eClass" : "https://strumenta.com/kolasu/transpilation/v1#//TranspilationTrace", @@ -69,7 +69,7 @@ def test_serialize_transpilation_issue(self): "severity" : "WARNING" } ] }""" - self.assertEquals(json.loads(expected), json.loads(tt.save_as_json("foo.json"))) + self.assertEqual(json.loads(expected), json.loads(tt.save_as_json("foo.json"))) def test_serialize_transpilation_from_nodes(self): mmb = MetamodelBuilder("tests.fixtures", "https://strumenta.com/pylasu/test/fixtures") @@ -112,4 +112,4 @@ def test_serialize_transpilation_from_nodes(self): } }""" as_json = tt.save_as_json("foo.json", mmb.generate()) - self.assertEquals(json.loads(expected), json.loads(as_json)) + self.assertEqual(json.loads(expected), json.loads(as_json)) diff --git a/tests/test_traversing.py b/tests/test_traversing.py index 06c57e2..8bc0246 100644 --- a/tests/test_traversing.py +++ b/tests/test_traversing.py @@ -6,34 +6,34 @@ class TraversingTest(unittest.TestCase): def test_walk_within_with_outside_position(self): - self.assertEquals([], [n.name for n in box.walk_within(pos(15, 1, 15, 1))]) + self.assertEqual([], [n.name for n in box.walk_within(pos(15, 1, 15, 1))]) def test_walk_within_with_root_position(self): - self.assertEquals( + self.assertEqual( ["root", "first", "1", "2", "big", "small", "3", "4", "5", "6"], [n.name for n in box.walk_within(box.position)] ) def test_walk_within_with_leaf_position(self): - self.assertEquals(["6"], [n.name for n in box.walk_within(pos(13, 3, 13, 9))]) + self.assertEqual(["6"], [n.name for n in box.walk_within(pos(13, 3, 13, 9))]) def test_walk_within_with_subtree_position(self): - self.assertEquals(["small", "3", "4", "5"], [n.name for n in box.walk_within(pos(7, 5, 11, 5))]) + self.assertEqual(["small", "3", "4", "5"], [n.name for n in box.walk_within(pos(7, 5, 11, 5))]) def test_walk_depth_first(self): - self.assertEquals( + self.assertEqual( ["root", "first", "1", "2", "big", "small", "3", "4", "5", "6"], [n.name for n in box.walk()] ) def test_walk_leaves_first(self): - self.assertEquals( + self.assertEqual( ["1", "first", "2", "3", "4", "5", "small", "big", "6", "root"], [n.name for n in box.walk_leaves_first()] ) def test_walk_descendants(self): - self.assertEquals( + self.assertEqual( ["first", "1", "2", "big", "small", "3", "4", "5", "6"], [n.name for n in box.walk_descendants()] ) @@ -41,4 +41,4 @@ def test_walk_descendants(self): def test_walk_ancestors(self): box.assign_parents() item4 = box.contents[2].contents[0].contents[1] - self.assertEquals(["small", "big", "root"], [n.name for n in item4.walk_ancestors()]) + self.assertEqual(["small", "big", "root"], [n.name for n in item4.walk_ancestors()]) diff --git a/tests/transformation/test_ast_transformers.py b/tests/transformation/test_ast_transformers.py index a5d9dd4..383a89e 100644 --- a/tests/transformation/test_ast_transformers.py +++ b/tests/transformation/test_ast_transformers.py @@ -70,8 +70,8 @@ def test_identitiy_transformer(self): SetStatement(variable="foo", value=123), DisplayIntStatement(value=456)]) transformed_cu = transformer.transform(cu) - self.assertEquals(cu, transformed_cu) - self.assertEquals(transformed_cu.origin, cu) + self.assertEqual(cu, transformed_cu) + self.assertEqual(transformed_cu.origin, cu) def test_translate_binary_expression(self): """Example of transformation to perform a refactoring within the same language.""" @@ -87,7 +87,7 @@ def generic_binary_expression_to_ast(source: GenericBinaryExpression): my_transformer.register_identity_transformation(IntLiteral) source = GenericBinaryExpression(Operator.MULT, IntLiteral(7), IntLiteral(8)) t1 = my_transformer.transform(source) - self.assertEquals(t1, source.to_ast()) + self.assertEqual(t1, source.to_ast()) def test_translate_across_languages(self): transformer = ASTTransformer(allow_generic_node=False) @@ -98,7 +98,7 @@ def test_translate_across_languages(self): transformer.register_node_factory( ALangMult, lambda source: BLangMult(transformer.transform(source.left), transformer.transform(source.right))) - self.assertEquals( + self.assertEqual( BLangMult( BLangSum( BLangIntLiteral(1), @@ -123,8 +123,8 @@ def test_dropping_nodes(self): cu = CU(statements=[DisplayIntStatement(value=456), SetStatement(variable="foo", value=123)]) transformed_cu = transformer.transform(cu) # TODO not yet supported self.assertTrue(transformed_cu.hasValidParents()) - self.assertEquals(transformed_cu.origin, cu) - self.assertEquals(1, len(transformed_cu.statements)) + self.assertEqual(transformed_cu.origin, cu) + self.assertEqual(1, len(transformed_cu.statements)) assert_asts_are_equal(self, cu.statements[1], transformed_cu.statements[0]) def test_nested_origin(self): @@ -135,7 +135,7 @@ def test_nested_origin(self): cu = CU(statements=[DisplayIntStatement(value=456)]) transformed_cu = transformer.transform(cu) # TODO not yet supported self.assertTrue(transformed_cu.hasValidParents()) - self.assertEquals(transformed_cu.origin, cu) + self.assertEqual(transformed_cu.origin, cu) self.assertIsInstance(transformed_cu.statements[0].origin, GenericNode) def test_transforming_one_node_to_many(self): @@ -146,7 +146,7 @@ def test_transforming_one_node_to_many(self): original = BarRoot([BarStmt("a"), BarStmt("b")]) transformed = transformer.transform(original) # TODO not yet supported assertTrue { transformed.hasValidParents() } - self.assertEquals(transformed.origin, original) + self.assertEqual(transformed.origin, original) assert_asts_are_equal( self, BazRoot([BazStmt("a-1"), BazStmt("a-2"), BazStmt("b-1"), BazStmt("b-2")]),