Commit 47102585 authored by Stefan Behnel's avatar Stefan Behnel

Rename unit test method calls from "assertEquals" to "assertEqual" to fix a a...

Rename unit test method calls from "assertEquals" to "assertEqual" to fix a a deprecation warning in Py3.7.
parent a5481d3d
...@@ -45,7 +45,7 @@ class TestTreeFragments(CythonTest): ...@@ -45,7 +45,7 @@ class TestTreeFragments(CythonTest):
T = F.substitute({"v" : NameNode(pos=None, name="a")}) T = F.substitute({"v" : NameNode(pos=None, name="a")})
v = F.root.stats[1].rhs.operand2.operand1 v = F.root.stats[1].rhs.operand2.operand1
a = T.stats[1].rhs.operand2.operand1 a = T.stats[1].rhs.operand2.operand1
self.assertEquals(v.pos, a.pos) self.assertEqual(v.pos, a.pos)
def test_temps(self): def test_temps(self):
TemplateTransform.temp_name_counter = 0 TemplateTransform.temp_name_counter = 0
......
...@@ -20,75 +20,75 @@ class TestTreePath(TransformTest): ...@@ -20,75 +20,75 @@ class TestTreePath(TransformTest):
def test_node_path(self): def test_node_path(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(2, len(find_all(t, "//DefNode"))) self.assertEqual(2, len(find_all(t, "//DefNode")))
self.assertEquals(2, len(find_all(t, "//NameNode"))) self.assertEqual(2, len(find_all(t, "//NameNode")))
self.assertEquals(1, len(find_all(t, "//ReturnStatNode"))) self.assertEqual(1, len(find_all(t, "//ReturnStatNode")))
self.assertEquals(1, len(find_all(t, "//DefNode//ReturnStatNode"))) self.assertEqual(1, len(find_all(t, "//DefNode//ReturnStatNode")))
def test_node_path_star(self): def test_node_path_star(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(10, len(find_all(t, "//*"))) self.assertEqual(10, len(find_all(t, "//*")))
self.assertEquals(8, len(find_all(t, "//DefNode//*"))) self.assertEqual(8, len(find_all(t, "//DefNode//*")))
self.assertEquals(0, len(find_all(t, "//NameNode//*"))) self.assertEqual(0, len(find_all(t, "//NameNode//*")))
def test_node_path_attribute(self): def test_node_path_attribute(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(2, len(find_all(t, "//NameNode/@name"))) self.assertEqual(2, len(find_all(t, "//NameNode/@name")))
self.assertEquals(['fun', 'decorator'], find_all(t, "//NameNode/@name")) self.assertEqual(['fun', 'decorator'], find_all(t, "//NameNode/@name"))
def test_node_path_attribute_dotted(self): def test_node_path_attribute_dotted(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(1, len(find_all(t, "//ReturnStatNode/@value.name"))) self.assertEqual(1, len(find_all(t, "//ReturnStatNode/@value.name")))
self.assertEquals(['fun'], find_all(t, "//ReturnStatNode/@value.name")) self.assertEqual(['fun'], find_all(t, "//ReturnStatNode/@value.name"))
def test_node_path_child(self): def test_node_path_child(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(1, len(find_all(t, "//DefNode/ReturnStatNode/NameNode"))) self.assertEqual(1, len(find_all(t, "//DefNode/ReturnStatNode/NameNode")))
self.assertEquals(1, len(find_all(t, "//ReturnStatNode/NameNode"))) self.assertEqual(1, len(find_all(t, "//ReturnStatNode/NameNode")))
def test_node_path_node_predicate(self): def test_node_path_node_predicate(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(0, len(find_all(t, "//DefNode[.//ForInStatNode]"))) self.assertEqual(0, len(find_all(t, "//DefNode[.//ForInStatNode]")))
self.assertEquals(2, len(find_all(t, "//DefNode[.//NameNode]"))) self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode]")))
self.assertEquals(1, len(find_all(t, "//ReturnStatNode[./NameNode]"))) self.assertEqual(1, len(find_all(t, "//ReturnStatNode[./NameNode]")))
self.assertEquals(Nodes.ReturnStatNode, self.assertEqual(Nodes.ReturnStatNode,
type(find_first(t, "//ReturnStatNode[./NameNode]"))) type(find_first(t, "//ReturnStatNode[./NameNode]")))
def test_node_path_node_predicate_step(self): def test_node_path_node_predicate_step(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(2, len(find_all(t, "//DefNode[.//NameNode]"))) self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode]")))
self.assertEquals(8, len(find_all(t, "//DefNode[.//NameNode]//*"))) self.assertEqual(8, len(find_all(t, "//DefNode[.//NameNode]//*")))
self.assertEquals(1, len(find_all(t, "//DefNode[.//NameNode]//ReturnStatNode"))) self.assertEqual(1, len(find_all(t, "//DefNode[.//NameNode]//ReturnStatNode")))
self.assertEquals(Nodes.ReturnStatNode, self.assertEqual(Nodes.ReturnStatNode,
type(find_first(t, "//DefNode[.//NameNode]//ReturnStatNode"))) type(find_first(t, "//DefNode[.//NameNode]//ReturnStatNode")))
def test_node_path_attribute_exists(self): def test_node_path_attribute_exists(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(2, len(find_all(t, "//NameNode[@name]"))) self.assertEqual(2, len(find_all(t, "//NameNode[@name]")))
self.assertEquals(ExprNodes.NameNode, self.assertEqual(ExprNodes.NameNode,
type(find_first(t, "//NameNode[@name]"))) type(find_first(t, "//NameNode[@name]")))
def test_node_path_attribute_exists_not(self): def test_node_path_attribute_exists_not(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(0, len(find_all(t, "//NameNode[not(@name)]"))) self.assertEqual(0, len(find_all(t, "//NameNode[not(@name)]")))
self.assertEquals(2, len(find_all(t, "//NameNode[not(@honking)]"))) self.assertEqual(2, len(find_all(t, "//NameNode[not(@honking)]")))
def test_node_path_and(self): def test_node_path_and(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(1, len(find_all(t, "//DefNode[.//ReturnStatNode and .//NameNode]"))) self.assertEqual(1, len(find_all(t, "//DefNode[.//ReturnStatNode and .//NameNode]")))
self.assertEquals(0, len(find_all(t, "//NameNode[@honking and @name]"))) self.assertEqual(0, len(find_all(t, "//NameNode[@honking and @name]")))
self.assertEquals(0, len(find_all(t, "//NameNode[@name and @honking]"))) self.assertEqual(0, len(find_all(t, "//NameNode[@name and @honking]")))
self.assertEquals(2, len(find_all(t, "//DefNode[.//NameNode[@name] and @name]"))) self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode[@name] and @name]")))
def test_node_path_attribute_string_predicate(self): def test_node_path_attribute_string_predicate(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(1, len(find_all(t, "//NameNode[@name = 'decorator']"))) self.assertEqual(1, len(find_all(t, "//NameNode[@name = 'decorator']")))
def test_node_path_recursive_predicate(self): def test_node_path_recursive_predicate(self):
t = self._build_tree() t = self._build_tree()
self.assertEquals(2, len(find_all(t, "//DefNode[.//NameNode[@name]]"))) self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode[@name]]")))
self.assertEquals(1, len(find_all(t, "//DefNode[.//NameNode[@name = 'decorator']]"))) self.assertEqual(1, len(find_all(t, "//DefNode[.//NameNode[@name = 'decorator']]")))
self.assertEquals(1, len(find_all(t, "//DefNode[.//ReturnStatNode[./NameNode[@name = 'fun']]/NameNode]"))) self.assertEqual(1, len(find_all(t, "//DefNode[.//ReturnStatNode[./NameNode[@name = 'fun']]/NameNode]")))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -23,27 +23,27 @@ class TestUtilityLoader(unittest.TestCase): ...@@ -23,27 +23,27 @@ class TestUtilityLoader(unittest.TestCase):
def test_load_as_string(self): def test_load_as_string(self):
got = strip_2tup(self.cls.load_as_string(self.name)) got = strip_2tup(self.cls.load_as_string(self.name))
self.assertEquals(got, self.expected) self.assertEqual(got, self.expected)
got = strip_2tup(self.cls.load_as_string(self.name, self.filename)) got = strip_2tup(self.cls.load_as_string(self.name, self.filename))
self.assertEquals(got, self.expected) self.assertEqual(got, self.expected)
def test_load(self): def test_load(self):
utility = self.cls.load(self.name) utility = self.cls.load(self.name)
got = strip_2tup((utility.proto, utility.impl)) got = strip_2tup((utility.proto, utility.impl))
self.assertEquals(got, self.expected) self.assertEqual(got, self.expected)
required, = utility.requires required, = utility.requires
got = strip_2tup((required.proto, required.impl)) got = strip_2tup((required.proto, required.impl))
self.assertEquals(got, self.required) self.assertEqual(got, self.required)
utility = self.cls.load(self.name, from_file=self.filename) utility = self.cls.load(self.name, from_file=self.filename)
got = strip_2tup((utility.proto, utility.impl)) got = strip_2tup((utility.proto, utility.impl))
self.assertEquals(got, self.expected) self.assertEqual(got, self.expected)
utility = self.cls.load_cached(self.name, from_file=self.filename) utility = self.cls.load_cached(self.name, from_file=self.filename)
got = strip_2tup((utility.proto, utility.impl)) got = strip_2tup((utility.proto, utility.impl))
self.assertEquals(got, self.expected) self.assertEqual(got, self.expected)
class TestTempitaUtilityLoader(TestUtilityLoader): class TestTempitaUtilityLoader(TestUtilityLoader):
...@@ -60,20 +60,20 @@ class TestTempitaUtilityLoader(TestUtilityLoader): ...@@ -60,20 +60,20 @@ class TestTempitaUtilityLoader(TestUtilityLoader):
def test_load_as_string(self): def test_load_as_string(self):
got = strip_2tup(self.cls.load_as_string(self.name, context=self.context)) got = strip_2tup(self.cls.load_as_string(self.name, context=self.context))
self.assertEquals(got, self.expected_tempita) self.assertEqual(got, self.expected_tempita)
def test_load(self): def test_load(self):
utility = self.cls.load(self.name, context=self.context) utility = self.cls.load(self.name, context=self.context)
got = strip_2tup((utility.proto, utility.impl)) got = strip_2tup((utility.proto, utility.impl))
self.assertEquals(got, self.expected_tempita) self.assertEqual(got, self.expected_tempita)
required, = utility.requires required, = utility.requires
got = strip_2tup((required.proto, required.impl)) got = strip_2tup((required.proto, required.impl))
self.assertEquals(got, self.required_tempita) self.assertEqual(got, self.required_tempita)
utility = self.cls.load(self.name, from_file=self.filename, context=self.context) utility = self.cls.load(self.name, from_file=self.filename, context=self.context)
got = strip_2tup((utility.proto, utility.impl)) got = strip_2tup((utility.proto, utility.impl))
self.assertEquals(got, self.expected_tempita) self.assertEqual(got, self.expected_tempita)
class TestCythonUtilityLoader(TestTempitaUtilityLoader): class TestCythonUtilityLoader(TestTempitaUtilityLoader):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment