Commit 886d2fbc authored by Denis Bilenko's avatar Denis Bilenko

fix tests in test__threadpool.py

parent a3734597
...@@ -42,6 +42,7 @@ class PoolBasicTests(TestCase): ...@@ -42,6 +42,7 @@ class PoolBasicTests(TestCase):
def test_init_valuerror(self): def test_init_valuerror(self):
self.switch_expected = False self.switch_expected = False
self.assertRaises(ValueError, ThreadPool, -1) self.assertRaises(ValueError, ThreadPool, -1)
self.pool = None
# #
# tests from standard library test/test_multiprocessing.py # tests from standard library test/test_multiprocessing.py
...@@ -197,8 +198,8 @@ class TestJoinEmpty(TestCase): ...@@ -197,8 +198,8 @@ class TestJoinEmpty(TestCase):
switch_expected = False switch_expected = False
def test(self): def test(self):
pool = ThreadPool(1) self.pool = ThreadPool(1)
pool.join() self.pool.join()
class TestSpawn(TestCase): class TestSpawn(TestCase):
...@@ -243,20 +244,15 @@ class TestErrorInIterator(TestCase): ...@@ -243,20 +244,15 @@ class TestErrorInIterator(TestCase):
class TestMaxsize(TestCase): class TestMaxsize(TestCase):
__timeout__ = 50
def test_inc(self): def test_inc(self):
self.pool = ThreadPool(0) self.pool = ThreadPool(0)
done = [] done = []
gevent.spawn(self.pool.spawn, done.append, 1) gevent.spawn(self.pool.spawn, done.append, 1)
gevent.spawn(self.pool.spawn, done.append, 2) gevent.spawn(self.pool.spawn, done.append, 2)
print 'sleeping' gevent.sleep(0.001)
gevent.sleep(5)
self.assertEqual(done, []) self.assertEqual(done, [])
print 'updating maxsize'
self.pool.maxsize = 1 self.pool.maxsize = 1
print 'sleeping' gevent.sleep(0.001)
gevent.sleep(5)
self.assertEqual(done, [2, 1]) self.assertEqual(done, [2, 1])
......
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