Skip to content

Commit 2c1390f

Browse files
committed
Simplified test suite for pool design pattern
1 parent af654f6 commit 2c1390f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/test_pool.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import unittest
4+
try:
5+
import queue
6+
except ImportError: # python 2.x compatibility
7+
import Queue as queue
8+
from creational.pool import QueueObject
9+
10+
11+
class TestPool(unittest.TestCase):
12+
13+
def setUp(self):
14+
15+
def test_object(queue):
16+
queue_object = QueueObject(queue, True)
17+
print('Inside func: {}'.format(queue_object.object))
18+
19+
def test_pool_behavior(self):
20+
sample_queue = queue.Queue()
21+
sample_queue.put('yam')
22+
self.assertTrue(sample_queue.get() == 'yam')
23+
# with QueueObject(sample_queue) as obj:
24+
# print('Inside with: {}'.format(obj))
25+
26+
# sample_queue.put('sam')
27+
# test_object(sample_queue)
28+
# print('Outside func: {}'.format(sample_queue.get()))
29+
30+
# if not sample_queue.empty():
31+
# print(sample_queue.get())
32+
33+
34+
# if __name__ == '__main__':
35+
# main()
36+
37+
### OUTPUT ###
38+
# Inside with: yam
39+
# Outside with: yam
40+
# Inside func: sam
41+
# Outside func: sam
42+

0 commit comments

Comments
 (0)