Merge "Replace xrange in for loop with range"
This commit is contained in:
@@ -135,7 +135,7 @@ class QueueFunctionManager(object):
|
|||||||
self.thread_kwargs = thread_kwargs if thread_kwargs else {}
|
self.thread_kwargs = thread_kwargs if thread_kwargs else {}
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
for _junk in xrange(self.thread_count):
|
for _junk in range(self.thread_count):
|
||||||
if self.connection_maker:
|
if self.connection_maker:
|
||||||
thread_args = (self.connection_maker(),) + self.thread_args
|
thread_args = (self.connection_maker(),) + self.thread_args
|
||||||
else:
|
else:
|
||||||
|
@@ -153,14 +153,14 @@ class TestQueueFunctionManager(ThreadTestCase):
|
|||||||
with self.qfq as input_queue:
|
with self.qfq as input_queue:
|
||||||
self.assertEqual(self.starting_thread_count + self.thread_count,
|
self.assertEqual(self.starting_thread_count + self.thread_count,
|
||||||
threading.active_count())
|
threading.active_count())
|
||||||
for i in xrange(20):
|
for i in range(20):
|
||||||
input_queue.put('slap%d' % i)
|
input_queue.put('slap%d' % i)
|
||||||
|
|
||||||
self.assertEqual(self.starting_thread_count, threading.active_count())
|
self.assertEqual(self.starting_thread_count, threading.active_count())
|
||||||
self.assertEqual([], self.thread_manager.error.call_args_list)
|
self.assertEqual([], self.thread_manager.error.call_args_list)
|
||||||
self.assertEqual(0, self.error_counter[0])
|
self.assertEqual(0, self.error_counter[0])
|
||||||
self.assertQueueContains(self.got_items,
|
self.assertQueueContains(self.got_items,
|
||||||
set(['slap%d' % i for i in xrange(20)]))
|
set(['slap%d' % i for i in range(20)]))
|
||||||
self.assertQueueContains(
|
self.assertQueueContains(
|
||||||
self.got_args_kwargs,
|
self.got_args_kwargs,
|
||||||
[(('1arg', '2arg'), {'a': 'b'})] * 20)
|
[(('1arg', '2arg'), {'a': 'b'})] * 20)
|
||||||
@@ -170,7 +170,7 @@ class TestQueueFunctionManager(ThreadTestCase):
|
|||||||
with self.qfq as input_queue:
|
with self.qfq as input_queue:
|
||||||
self.assertEqual(self.starting_thread_count + self.thread_count,
|
self.assertEqual(self.starting_thread_count + self.thread_count,
|
||||||
threading.active_count())
|
threading.active_count())
|
||||||
for i in xrange(20):
|
for i in range(20):
|
||||||
input_queue.put('item%d' % i if i % 2 == 0 else 'go boom')
|
input_queue.put('item%d' % i if i % 2 == 0 else 'go boom')
|
||||||
|
|
||||||
self.assertEqual(self.starting_thread_count, threading.active_count())
|
self.assertEqual(self.starting_thread_count, threading.active_count())
|
||||||
@@ -179,8 +179,9 @@ class TestQueueFunctionManager(ThreadTestCase):
|
|||||||
self.assertTrue(all(['Exception: I went boom!' in s for s in
|
self.assertTrue(all(['Exception: I went boom!' in s for s in
|
||||||
error_strs]))
|
error_strs]))
|
||||||
self.assertEqual(10, self.error_counter[0])
|
self.assertEqual(10, self.error_counter[0])
|
||||||
expected_items = set(['go boom'] + ['item%d' % i for i in xrange(20)
|
expected_items = set(['go boom'] +
|
||||||
if i % 2 == 0])
|
['item%d' % i for i in range(20)
|
||||||
|
if i % 2 == 0])
|
||||||
self.assertQueueContains(self.got_items, expected_items)
|
self.assertQueueContains(self.got_items, expected_items)
|
||||||
self.assertQueueContains(
|
self.assertQueueContains(
|
||||||
self.got_args_kwargs,
|
self.got_args_kwargs,
|
||||||
@@ -191,7 +192,7 @@ class TestQueueFunctionManager(ThreadTestCase):
|
|||||||
with self.qfq as input_queue:
|
with self.qfq as input_queue:
|
||||||
self.assertEqual(self.starting_thread_count + self.thread_count,
|
self.assertEqual(self.starting_thread_count + self.thread_count,
|
||||||
threading.active_count())
|
threading.active_count())
|
||||||
for i in xrange(20):
|
for i in range(20):
|
||||||
input_queue.put('item%d' % i if i % 2 == 0 else 'c boom')
|
input_queue.put('item%d' % i if i % 2 == 0 else 'c boom')
|
||||||
|
|
||||||
self.assertEqual(self.starting_thread_count, threading.active_count())
|
self.assertEqual(self.starting_thread_count, threading.active_count())
|
||||||
@@ -201,8 +202,9 @@ class TestQueueFunctionManager(ThreadTestCase):
|
|||||||
'http://192.168.22.1:80/booze 404 to much no sir!'
|
'http://192.168.22.1:80/booze 404 to much no sir!'
|
||||||
self.assertTrue(all([stringification in s for s in error_strs]))
|
self.assertTrue(all([stringification in s for s in error_strs]))
|
||||||
self.assertEqual(10, self.error_counter[0])
|
self.assertEqual(10, self.error_counter[0])
|
||||||
expected_items = set(['c boom'] + ['item%d' % i for i in xrange(20)
|
expected_items = set(['c boom'] +
|
||||||
if i % 2 == 0])
|
['item%d' % i for i in range(20)
|
||||||
|
if i % 2 == 0])
|
||||||
self.assertQueueContains(self.got_items, expected_items)
|
self.assertQueueContains(self.got_items, expected_items)
|
||||||
self.assertQueueContains(
|
self.assertQueueContains(
|
||||||
self.got_args_kwargs,
|
self.got_args_kwargs,
|
||||||
@@ -213,14 +215,14 @@ class TestQueueFunctionManager(ThreadTestCase):
|
|||||||
with self.qfq as input_queue:
|
with self.qfq as input_queue:
|
||||||
self.assertEqual(self.starting_thread_count + self.thread_count,
|
self.assertEqual(self.starting_thread_count + self.thread_count,
|
||||||
threading.active_count())
|
threading.active_count())
|
||||||
for i in xrange(20):
|
for i in range(20):
|
||||||
input_queue.put('item%d' % i)
|
input_queue.put('item%d' % i)
|
||||||
|
|
||||||
self.assertEqual(self.starting_thread_count, threading.active_count())
|
self.assertEqual(self.starting_thread_count, threading.active_count())
|
||||||
self.assertEqual([], self.thread_manager.error.call_args_list)
|
self.assertEqual([], self.thread_manager.error.call_args_list)
|
||||||
self.assertEqual(0, self.error_counter[0])
|
self.assertEqual(0, self.error_counter[0])
|
||||||
self.assertQueueContains(self.got_items,
|
self.assertQueueContains(self.got_items,
|
||||||
set(['item%d' % i for i in xrange(20)]))
|
set(['item%d' % i for i in range(20)]))
|
||||||
self.assertQueueContains(
|
self.assertQueueContains(
|
||||||
self.got_args_kwargs,
|
self.got_args_kwargs,
|
||||||
[(('yup, I made a connection', '1arg', '2arg'), {'a': 'b'})] * 20)
|
[(('yup, I made a connection', '1arg', '2arg'), {'a': 'b'})] * 20)
|
||||||
|
Reference in New Issue
Block a user