@@ -51,32 +51,34 @@ def __del__(self):
5151
5252
5353def main ():
54- import queue
54+ """
55+ >>> import queue
5556
56- def test_object (queue ):
57- pool = ObjectPool (queue , True )
58- print ('Inside func: {}' .format (pool .item ))
57+ >>> def test_object(queue):
58+ ... pool = ObjectPool(queue, True)
59+ ... print('Inside func: {}'.format(pool.item))
5960
60- sample_queue = queue .Queue ()
61+ >>> sample_queue = queue.Queue()
6162
62- sample_queue .put ('yam' )
63- with ObjectPool (sample_queue ) as obj :
64- print ('Inside with: {}' .format (obj ))
65- print ( 'Outside with: {}' . format ( sample_queue . get ()))
63+ >>> sample_queue.put('yam')
64+ >>> with ObjectPool(sample_queue) as obj:
65+ ... print('Inside with: {}'.format(obj))
66+ Inside with: yam
6667
67- sample_queue .put ('sam' )
68- test_object (sample_queue )
69- print ('Outside func: {}' .format (sample_queue .get ()))
68+ >>> print('Outside with: {}'.format(sample_queue.get()))
69+ Outside with: yam
70+
71+ >>> sample_queue.put('sam')
72+ >>> test_object(sample_queue)
73+ Inside func: sam
74+
75+ >>> print('Outside func: {}'.format(sample_queue.get()))
76+ Outside func: sam
7077
7178 if not sample_queue.empty():
7279 print(sample_queue.get())
73-
80+ """
7481
7582if __name__ == '__main__' :
76- main ()
77-
78- ### OUTPUT ###
79- # Inside with: yam
80- # Outside with: yam
81- # Inside func: sam
82- # Outside func: sam
83+ import doctest
84+ doctest .testmod ()
0 commit comments