示例#1
0
 def test_items_recoil(self):
     with ObjectPool(self.sample_queue, True) as pool:
         self.assertEqual(pool, 'first')
     self.assertTrue(self.sample_queue.get() == 'second')
     self.assertFalse(self.sample_queue.empty())
     self.assertTrue(self.sample_queue.get() == 'first')
     self.assertTrue(self.sample_queue.empty())
示例#2
0
 def test_pool_behavior_with_single_object_inside(self):
     sample_queue = queue.Queue()
     sample_queue.put('yam')
     with ObjectPool(sample_queue) as obj:
         # print('Inside with: {}'.format(obj))
         self.assertEqual(obj, 'yam')
     self.assertFalse(sample_queue.empty())
     self.assertTrue(sample_queue.get() == 'yam')
     self.assertTrue(sample_queue.empty())