Commit a14e8264 authored by Yury Selivanov's avatar Yury Selivanov

Fix Python 2 compat

parent 5dba8d39
......@@ -700,11 +700,10 @@ class TestBasic(greentest.TestCase):
gevent.sleep(0.01)
def test_add_spawn_callback(self):
called = 0
called = {'#': 0}
def cb(gr):
nonlocal called
called += 1
called['#'] += 1
gr._called_test = True
gevent.Greenlet.add_spawn_callback(cb)
......@@ -712,24 +711,24 @@ class TestBasic(greentest.TestCase):
g = gevent.spawn(lambda: None)
self.assertTrue(hasattr(g, '_called_test'))
g.join()
self.assertEqual(called, 1)
self.assertEqual(called['#'], 1)
g = gevent.spawn_later(1e-5, lambda: None)
self.assertTrue(hasattr(g, '_called_test'))
g.join()
self.assertEqual(called, 2)
self.assertEqual(called['#'], 2)
g = gevent.Greenlet(lambda: None)
g.start()
self.assertTrue(hasattr(g, '_called_test'))
g.join()
self.assertEqual(called, 3)
self.assertEqual(called['#'], 3)
gevent.Greenlet.remove_spawn_callback(cb)
g = gevent.spawn(lambda: None)
self.assertFalse(hasattr(g, '_called_test'))
g.join()
self.assertEqual(called, 3)
self.assertEqual(called['#'], 3)
finally:
gevent.Greenlet.remove_spawn_callback(cb)
......
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