Commits

Kyle Ambroff committed 9e69243

Get rid of deprecation warnings from unittest in Python 3.2.

  • Participants
  • Parent commits 04317c8

Comments (0)

Files changed (7)

File tests/test_extension_interface.py

 
 class CAPITests(unittest.TestCase):
     def test_switch(self):
-        self.assertEquals(
+        self.assertEqual(
             50, _test_extension.test_switch(greenlet.greenlet(lambda: 50)))
 
     def test_switch_kwargs(self):
         def foo(x, y):
             return x * y
         g = greenlet.greenlet(foo)
-        self.assertEquals(6, _test_extension.test_switch_kwargs(g, x=3, y=2))
+        self.assertEqual(6, _test_extension.test_switch_kwargs(g, x=3, y=2))
 
     def test_setparent(self):
         def foo():
             def bar():
                 greenlet.getcurrent().parent.switch()
 
-                # This final switch should go back to the main greenlet, since the
-                # test_setparent() function in the C extension should have
+                # This final switch should go back to the main greenlet, since
+                # the test_setparent() function in the C extension should have
                 # reparented this greenlet.
                 greenlet.getcurrent().parent.switch()
                 raise AssertionError("Should never have reached this code")
             greenlet.getcurrent().parent.throw(
                 AssertionError("Should never reach this code"))
         foo_child = greenlet.greenlet(foo).switch()
-        self.assertEquals(None, _test_extension.test_setparent(foo_child))
+        self.assertEqual(None, _test_extension.test_setparent(foo_child))
 
     def test_getcurrent(self):
         _test_extension.test_getcurrent()
 
     def test_new_greenlet(self):
-        self.assertEquals(-15, _test_extension.test_new_greenlet(lambda: -15))
+        self.assertEqual(-15, _test_extension.test_new_greenlet(lambda: -15))
 
     def test_raise_greenlet_dead(self):
         self.assertRaises(
         g = greenlet.greenlet(foo)
         g.switch()
         _test_extension.test_throw(g)
-        self.assertEquals(len(seen), 1)
+        self.assertEqual(len(seen), 1)
         self.assertTrue(
             isinstance(seen[0], ValueError),
             "ValueError was not raised in foo()")
-        self.assertEquals(
+        self.assertEqual(
             str(seen[0]),
             'take that sucka!',
             "message doesn't match")

File tests/test_generator.py

         for k in range(3):
             for j in g(5):
                 seen.append(j)
-        self.assertEquals(seen, 3 * [0, 0, 1, 1, 2, 2, 3, 3, 4, 4])
+        self.assertEqual(seen, 3 * [0, 0, 1, 1, 2, 2, 3, 3, 4, 4])

File tests/test_generator_nested.py

         seen = []
         for ii in gr2(5, seen):
             seen.append(ii)
-        self.assertEquals(seen, [1, 1, 2, 4, 3, 9, 4, 16])
+        self.assertEqual(seen, [1, 1, 2, 4, 3, 9, 4, 16])
 
     def test_permutations(self):
         gen_perms = perms(list(range(4)))
         permutations = list(gen_perms)
-        self.assertEquals(len(permutations), 4*3*2*1)
+        self.assertEqual(len(permutations), 4*3*2*1)
         self.assertTrue([0,1,2,3] in permutations)
         self.assertTrue([3,2,1,0] in permutations)
         res = []
         for ii in zip(perms(list(range(4))), perms(list(range(3)))):
             res.append(ii)
-        self.assertEquals(
+        self.assertEqual(
             res,
             [([0, 1, 2, 3], [0, 1, 2]), ([0, 1, 3, 2], [0, 2, 1]),
              ([0, 2, 1, 3], [1, 0, 2]), ([0, 2, 3, 1], [1, 2, 0]),
             for k in range(3):
                 for j in g(5, seen):
                     seen.append(j)
-            self.assertEquals(seen, 3 * [1, 0, 2, 1, 3, 2, 4, 3, 5, 4])
+            self.assertEqual(seen, 3 * [1, 0, 2, 1, 3, 2, 4, 3, 5, 4])
 
     def test_genlet_bad(self):
         try:

File tests/test_greenlet.py

         lst.append(2)
         g.switch()
         lst.append(4)
-        self.assertEquals(lst, list(range(5)))
+        self.assertEqual(lst, list(range(5)))
 
     def test_parent_equals_None(self):
         g = greenlet(parent=None)
             th.start()
         for th in ths:
             th.join()
-        self.assertEquals(len(success), len(ths))
+        self.assertEqual(len(success), len(ths))
 
     def test_exception(self):
         seen = []
         g1.switch(seen)
         g2.switch(seen)
         g2.parent = g1
-        self.assertEquals(seen, [])
+        self.assertEqual(seen, [])
         self.assertRaises(SomeError, g2.switch)
-        self.assertEquals(seen, [SomeError])
+        self.assertEqual(seen, [SomeError])
         g2.switch()
-        self.assertEquals(seen, [SomeError])
+        self.assertEqual(seen, [SomeError])
 
     def test_send_exception(self):
         seen = []
         g1 = greenlet(fmain)
         g1.switch(seen)
         self.assertRaises(KeyError, send_exception, g1, KeyError)
-        self.assertEquals(seen, [KeyError])
+        self.assertEqual(seen, [KeyError])
 
     def test_dealloc(self):
         seen = []
         g2 = greenlet(fmain)
         g1.switch(seen)
         g2.switch(seen)
-        self.assertEquals(seen, [])
+        self.assertEqual(seen, [])
         del g1
         gc.collect()
-        self.assertEquals(seen, [greenlet.GreenletExit])
+        self.assertEqual(seen, [greenlet.GreenletExit])
         del g2
         gc.collect()
-        self.assertEquals(seen, [greenlet.GreenletExit, greenlet.GreenletExit])
+        self.assertEqual(seen, [greenlet.GreenletExit, greenlet.GreenletExit])
 
     def test_dealloc_other_thread(self):
         seen = []
         t = threading.Thread(target=f)
         t.start()
         lock.acquire()
-        self.assertEquals(seen, [])
-        self.assertEquals(len(someref), 1)
+        self.assertEqual(seen, [])
+        self.assertEqual(len(someref), 1)
         del someref[:]
         gc.collect()
         # g1 is not released immediately because it's from another thread
-        self.assertEquals(seen, [])
+        self.assertEqual(seen, [])
         lock2.release()
         lock.acquire()
-        self.assertEquals(seen, [greenlet.GreenletExit])
+        self.assertEqual(seen, [greenlet.GreenletExit])
         lock2.release()
         t.join()
 
     def test_frame(self):
         def f1():
             f = sys._getframe(0)
-            self.assertEquals(f.f_back, None)
+            self.assertEqual(f.f_back, None)
             greenlet.getcurrent().parent.switch(f)
             return "meaning of life"
         g = greenlet(f1)
         self.assertTrue(g)
         next = g.switch()
         self.assertFalse(g)
-        self.assertEquals(next, 'meaning of life')
-        self.assertEquals(g.gr_frame, None)
+        self.assertEqual(next, 'meaning of life')
+        self.assertEqual(g.gr_frame, None)
 
     def test_thread_bug(self):
         def runner(x):
 
     def test_switch_kwargs(self):
         def foo(a, b):
-            self.assertEquals(a, 4)
-            self.assertEquals(b, 2)
+            self.assertEqual(a, 4)
+            self.assertEqual(b, 2)
         greenlet(foo).switch(a=4, b=2)
 
     def test_switch_kwargs_to_parent(self):
             greenlet.getcurrent().parent.switch(2, x=3)
             return x, x ** 2
         g = greenlet(foo)
-        self.assertEquals({'x': 3}, g.switch(3))
-        self.assertEquals(((2,), {'x': 3}), g.switch())
-        self.assertEquals((3, 9), g.switch())
+        self.assertEqual({'x': 3}, g.switch(3))
+        self.assertEqual(((2,), {'x': 3}), g.switch())
+        self.assertEqual((3, 9), g.switch())
 
     def test_switch_to_another_thread(self):
         data = {}

File tests/test_leaks.py

             lambda *args: greenlet.getcurrent().parent.switch(*args))
         for i in range(100):
             g.switch(*args)
-        self.assertEquals(sys.getrefcount(args), 3)
+        self.assertEqual(sys.getrefcount(args), 3)
 
     def test_kwarg_refs(self):
         kwargs = {}
             lambda **kwargs: greenlet.getcurrent().parent.switch(**kwargs))
         for i in range(100):
             g.switch(**kwargs)
-        self.assertEquals(sys.getrefcount(kwargs), 2)
+        self.assertEqual(sys.getrefcount(kwargs), 2)

File tests/test_throw.py

             switch("fail")
         g = greenlet(f)
         res = g.switch()
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
         res = g.throw(RuntimeError)
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
 
     def test_val(self):
         def f():
 
         g = greenlet(f)
         res = g.switch()
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
         res = g.throw(RuntimeError("ciao"))
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
 
         g = greenlet(f)
         res = g.switch()
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
         res = g.throw(RuntimeError, "ciao")
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
 
     def test_kill(self):
         def f():
             switch("fail")
         g = greenlet(f)
         res = g.switch()
-        self.assertEquals(res, "ok")
+        self.assertEqual(res, "ok")
         res = g.throw()
         self.assertTrue(isinstance(res, greenlet.GreenletExit))
         self.assertTrue(g.dead)
         g1 = greenlet(f1)
         g2 = greenlet(f2, parent=g1)
         res = g1.switch()
-        self.assertEquals(res, "f1 ready to catch")
+        self.assertEqual(res, "f1 ready to catch")
         res = g2.throw(IndexError)
-        self.assertEquals(res, "caught")
+        self.assertEqual(res, "caught")
         self.assertTrue(g2.dead)
         self.assertTrue(g1.dead)
 
         g1 = greenlet(f1)
         g2 = greenlet(f2, parent=g1)
         res = g1.switch()
-        self.assertEquals(res, "f1 ready to catch")
+        self.assertEqual(res, "f1 ready to catch")
         res = g2.switch()
-        self.assertEquals(res, "from f2")
+        self.assertEqual(res, "from f2")
         res = g2.throw(IndexError)
-        self.assertEquals(res, "caught")
+        self.assertEqual(res, "caught")
         self.assertTrue(g2.dead)
         self.assertTrue(g1.dead)

File tests/test_weakref.py

             return g
         o = weakref.ref(_dead_greenlet())
         gc.collect()
-        self.assertEquals(o(), None)
+        self.assertEqual(o(), None)
 
     def test_inactive_weakref(self):
         o = weakref.ref(greenlet.greenlet())
         gc.collect()
-        self.assertEquals(o(), None)
+        self.assertEqual(o(), None)