From 5e8d38e88513c9fd58506264c66a71df3fe55aa0 Mon Sep 17 00:00:00 2001
From: Stefan Behnel <stefan_ml@behnel.de>
Date: Thu, 14 Mar 2019 23:48:45 +0100
Subject: [PATCH] Fix some deprecated unittest method usages.

---
 Cython/Build/Tests/TestInline.py              | 18 +++++++--------
 Cython/Build/Tests/TestIpythonMagic.py        |  4 ++--
 Cython/Compiler/Tests/TestBuffer.py           | 22 +++++++++----------
 Cython/Compiler/Tests/TestMemView.py          |  2 +-
 .../Compiler/Tests/TestParseTreeTransforms.py |  2 +-
 Cython/Compiler/Tests/TestTreeFragment.py     | 10 ++++-----
 Cython/Tests/xmlrunner.py                     |  4 ++--
 7 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/Cython/Build/Tests/TestInline.py b/Cython/Build/Tests/TestInline.py
index 5ef9fec4e..d20948808 100644
--- a/Cython/Build/Tests/TestInline.py
+++ b/Cython/Build/Tests/TestInline.py
@@ -24,10 +24,10 @@ class TestInline(CythonTest):
         self.test_kwds['lib_dir'] = lib_dir
 
     def test_simple(self):
-        self.assertEquals(inline("return 1+2", **self.test_kwds), 3)
+        self.assertEqual(inline("return 1+2", **self.test_kwds), 3)
 
     def test_types(self):
-        self.assertEquals(inline("""
+        self.assertEqual(inline("""
             cimport cython
             return cython.typeof(a), cython.typeof(b)
         """, a=1.0, b=[], **self.test_kwds), ('double', 'list object'))
@@ -35,13 +35,13 @@ class TestInline(CythonTest):
     def test_locals(self):
         a = 1
         b = 2
-        self.assertEquals(inline("return a+b", **self.test_kwds), 3)
+        self.assertEqual(inline("return a+b", **self.test_kwds), 3)
 
     def test_globals(self):
-        self.assertEquals(inline("return global_value + 1", **self.test_kwds), global_value + 1)
+        self.assertEqual(inline("return global_value + 1", **self.test_kwds), global_value + 1)
 
     def test_no_return(self):
-        self.assertEquals(inline("""
+        self.assertEqual(inline("""
             a = 1
             cdef double b = 2
             cdef c = []
@@ -49,7 +49,7 @@ class TestInline(CythonTest):
 
     def test_def_node(self):
         foo = inline("def foo(x): return x * x", **self.test_kwds)['foo']
-        self.assertEquals(foo(7), 49)
+        self.assertEqual(foo(7), 49)
 
     def test_class_ref(self):
         class Type(object):
@@ -64,7 +64,7 @@ class TestInline(CythonTest):
         c = cy.declare(cy.pointer(cy.float), &b)
         return b
         """, a=3, **self.test_kwds)
-        self.assertEquals(type(b), float)
+        self.assertEqual(type(b), float)
 
     def test_compiler_directives(self):
         self.assertEqual(
@@ -92,5 +92,5 @@ class TestInline(CythonTest):
             import numpy
             a = numpy.ndarray((10, 20))
             a[0,0] = 10
-            self.assertEquals(safe_type(a), 'numpy.ndarray[numpy.float64_t, ndim=2]')
-            self.assertEquals(inline("return a[0,0]", a=a, **self.test_kwds), 10.0)
+            self.assertEqual(safe_type(a), 'numpy.ndarray[numpy.float64_t, ndim=2]')
+            self.assertEqual(inline("return a[0,0]", a=a, **self.test_kwds), 10.0)
diff --git a/Cython/Build/Tests/TestIpythonMagic.py b/Cython/Build/Tests/TestIpythonMagic.py
index d9d8322a8..24213091b 100644
--- a/Cython/Build/Tests/TestIpythonMagic.py
+++ b/Cython/Build/Tests/TestIpythonMagic.py
@@ -195,11 +195,11 @@ x = sin(0.0)
             ip.run_cell_magic('cython', '--verbose', code)
             ip.ex('g = f(10)')
         self.assertEqual(ip.user_ns['g'], 20.0)
-        self.assertEquals([verbose_log.INFO, verbose_log.DEBUG, verbose_log.INFO],
+        self.assertEqual([verbose_log.INFO, verbose_log.DEBUG, verbose_log.INFO],
                           verbose_log.thresholds)
 
         with mock_distutils() as normal_log:
             ip.run_cell_magic('cython', '', code)
             ip.ex('g = f(10)')
         self.assertEqual(ip.user_ns['g'], 20.0)
-        self.assertEquals([normal_log.INFO], normal_log.thresholds)
+        self.assertEqual([normal_log.INFO], normal_log.thresholds)
diff --git a/Cython/Compiler/Tests/TestBuffer.py b/Cython/Compiler/Tests/TestBuffer.py
index fcb22b72f..1f69d9652 100644
--- a/Cython/Compiler/Tests/TestBuffer.py
+++ b/Cython/Compiler/Tests/TestBuffer.py
@@ -21,7 +21,7 @@ class TestBufferParsing(CythonTest):
     def test_basic(self):
         t = self.parse(u"cdef object[float, 4, ndim=2, foo=foo] x")
         bufnode = t.stats[0].base_type
-        self.assert_(isinstance(bufnode, TemplatedTypeNode))
+        self.assertTrue(isinstance(bufnode, TemplatedTypeNode))
         self.assertEqual(2, len(bufnode.positional_args))
 #        print bufnode.dump()
         # should put more here...
@@ -46,7 +46,7 @@ class TestBufferOptions(CythonTest):
     def nonfatal_error(self, error):
         # We're passing self as context to transform to trap this
         self.error = error
-        self.assert_(self.expect_error)
+        self.assertTrue(self.expect_error)
 
     def parse_opts(self, opts, expect_error=False):
         assert opts != ""
@@ -57,12 +57,12 @@ class TestBufferOptions(CythonTest):
             vardef = root.stats[0].body.stats[0]
             assert isinstance(vardef, CVarDefNode) # use normal assert as this is to validate the test code
             buftype = vardef.base_type
-            self.assert_(isinstance(buftype, TemplatedTypeNode))
-            self.assert_(isinstance(buftype.base_type_node, CSimpleBaseTypeNode))
+            self.assertTrue(isinstance(buftype, TemplatedTypeNode))
+            self.assertTrue(isinstance(buftype.base_type_node, CSimpleBaseTypeNode))
             self.assertEqual(u"object", buftype.base_type_node.name)
             return buftype
         else:
-            self.assert_(len(root.stats[0].body.stats) == 0)
+            self.assertTrue(len(root.stats[0].body.stats) == 0)
 
     def non_parse(self, expected_err, opts):
         self.parse_opts(opts, expect_error=True)
@@ -71,14 +71,14 @@ class TestBufferOptions(CythonTest):
 
     def __test_basic(self):
         buf = self.parse_opts(u"unsigned short int, 3")
-        self.assert_(isinstance(buf.dtype_node, CSimpleBaseTypeNode))
-        self.assert_(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1)
+        self.assertTrue(isinstance(buf.dtype_node, CSimpleBaseTypeNode))
+        self.assertTrue(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1)
         self.assertEqual(3, buf.ndim)
 
     def __test_dict(self):
         buf = self.parse_opts(u"ndim=3, dtype=unsigned short int")
-        self.assert_(isinstance(buf.dtype_node, CSimpleBaseTypeNode))
-        self.assert_(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1)
+        self.assertTrue(isinstance(buf.dtype_node, CSimpleBaseTypeNode))
+        self.assertTrue(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1)
         self.assertEqual(3, buf.ndim)
 
     def __test_ndim(self):
@@ -94,8 +94,8 @@ class TestBufferOptions(CythonTest):
             cdef object[ndim=ndim, dtype=int] y
         """, pipeline=[NormalizeTree(self), PostParse(self)]).root
         stats = t.stats[0].body.stats
-        self.assert_(stats[0].base_type.ndim == 3)
-        self.assert_(stats[1].base_type.ndim == 3)
+        self.assertTrue(stats[0].base_type.ndim == 3)
+        self.assertTrue(stats[1].base_type.ndim == 3)
 
     # add exotic and impossible combinations as they come along...
 
diff --git a/Cython/Compiler/Tests/TestMemView.py b/Cython/Compiler/Tests/TestMemView.py
index 837bb8088..3792f26e9 100644
--- a/Cython/Compiler/Tests/TestMemView.py
+++ b/Cython/Compiler/Tests/TestMemView.py
@@ -48,7 +48,7 @@ class TestMemviewParsing(CythonTest):
     def test_basic(self):
         t = self.parse(u"cdef int[:] x")
         memv_node = t.stats[0].base_type
-        self.assert_(isinstance(memv_node, MemoryViewSliceTypeNode))
+        self.assertTrue(isinstance(memv_node, MemoryViewSliceTypeNode))
 
     # we also test other similar declarations (buffers, anonymous C arrays)
     # since the parsing has to distinguish between them.
diff --git a/Cython/Compiler/Tests/TestParseTreeTransforms.py b/Cython/Compiler/Tests/TestParseTreeTransforms.py
index 91e0e2f1d..234b45db5 100644
--- a/Cython/Compiler/Tests/TestParseTreeTransforms.py
+++ b/Cython/Compiler/Tests/TestParseTreeTransforms.py
@@ -87,7 +87,7 @@ class TestNormalizeTree(TransformTest):
 
     def test_pass_eliminated(self):
         t = self.run_pipeline([NormalizeTree(None)], u"pass")
-        self.assert_(len(t.stats) == 0)
+        self.assertTrue(len(t.stats) == 0)
 
 class TestWithTransform(object): # (TransformTest): # Disabled!
 
diff --git a/Cython/Compiler/Tests/TestTreeFragment.py b/Cython/Compiler/Tests/TestTreeFragment.py
index 3f15b7457..9ee8da547 100644
--- a/Cython/Compiler/Tests/TestTreeFragment.py
+++ b/Cython/Compiler/Tests/TestTreeFragment.py
@@ -23,7 +23,7 @@ class TestTreeFragments(CythonTest):
         T = self.fragment(u"y + y").substitute({"y": NameNode(pos=None, name="x")})
         self.assertEqual("x", T.stats[0].expr.operand1.name)
         self.assertEqual("x", T.stats[0].expr.operand2.name)
-        self.assert_(T.stats[0].expr.operand1 is not T.stats[0].expr.operand2)
+        self.assertTrue(T.stats[0].expr.operand1 is not T.stats[0].expr.operand2)
 
     def test_substitution(self):
         F = self.fragment(u"x = 4")
@@ -35,7 +35,7 @@ class TestTreeFragments(CythonTest):
         F = self.fragment(u"PASS")
         pass_stat = PassStatNode(pos=None)
         T = F.substitute({"PASS" : pass_stat})
-        self.assert_(isinstance(T.stats[0], PassStatNode), T)
+        self.assertTrue(isinstance(T.stats[0], PassStatNode), T)
 
     def test_pos_is_transferred(self):
         F = self.fragment(u"""
@@ -55,9 +55,9 @@ class TestTreeFragments(CythonTest):
         """)
         T = F.substitute(temps=[u"TMP"])
         s = T.body.stats
-        self.assert_(isinstance(s[0].expr, TempRefNode))
-        self.assert_(isinstance(s[1].rhs, TempRefNode))
-        self.assert_(s[0].expr.handle is s[1].rhs.handle)
+        self.assertTrue(isinstance(s[0].expr, TempRefNode))
+        self.assertTrue(isinstance(s[1].rhs, TempRefNode))
+        self.assertTrue(s[0].expr.handle is s[1].rhs.handle)
 
 if __name__ == "__main__":
     import unittest
diff --git a/Cython/Tests/xmlrunner.py b/Cython/Tests/xmlrunner.py
index 45df17f95..d6838aa22 100644
--- a/Cython/Tests/xmlrunner.py
+++ b/Cython/Tests/xmlrunner.py
@@ -27,12 +27,12 @@ class TestSequenceFunctions(unittest.TestCase):
 
     def test_choice(self):
         element = random.choice(self.seq)
-        self.assert_(element in self.seq)
+        self.assertTrue(element in self.seq)
 
     def test_sample(self):
         self.assertRaises(ValueError, random.sample, self.seq, 20)
         for element in random.sample(self.seq, 5):
-            self.assert_(element in self.seq)
+            self.assertTrue(element in self.seq)
 
 if __name__ == '__main__':
     unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
-- 
2.30.9