[Python-checkins] python/dist/src/Lib/test test_queue.py,1.2,1.3

loewis@users.sourceforge.net loewis@users.sourceforge.net
2002年10月15日 08:11:15 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv14777/Lib/test
Modified Files:
	test_queue.py 
Log Message:
Patch #572628: Optional timeouts for put and get.
Index: test_queue.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_queue.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_queue.py	23 Jul 2002 19:03:59 -0000	1.2
--- test_queue.py	15 Oct 2002 15:11:13 -0000	1.3
***************
*** 61,66 ****
 for i in range(queue_size-1):
 q.put(i)
- q.fail_next_put = True
 # Test a failing non-blocking put.
 try:
 q.put("oops", block=0)
--- 61,66 ----
 for i in range(queue_size-1):
 q.put(i)
 # Test a failing non-blocking put.
+ q.fail_next_put = True
 try:
 q.put("oops", block=0)
***************
*** 68,75 ****
 except FailingQueueException:
 pass
 q.put("last")
 verify(q.full(), "Queue should be full")
- q.fail_next_put = True
 # Test a failing blocking put
 try:
 _doBlockingTest( q.put, ("full",), q.get, ())
--- 68,81 ----
 except FailingQueueException:
 pass
+ q.fail_next_put = True
+ try:
+ q.put("oops", timeout=0.1)
+ raise TestFailed("The queue didn't fail when it should have")
+ except FailingQueueException:
+ pass
 q.put("last")
 verify(q.full(), "Queue should be full")
 # Test a failing blocking put
+ q.fail_next_put = True
 try:
 _doBlockingTest( q.put, ("full",), q.get, ())
***************
*** 80,83 ****
--- 86,99 ----
 # put failed, but get succeeded - re-add
 q.put("last")
+ # Test a failing timeout put
+ q.fail_next_put = True
+ try:
+ _doBlockingTest( q.put, ("full", True, 0.2), q.get, ())
+ raise TestFailed("The queue didn't fail when it should have")
+ except FailingQueueException:
+ pass
+ # Check the Queue isn't damaged.
+ # put failed, but get succeeded - re-add
+ q.put("last")
 verify(q.full(), "Queue should be full")
 q.get()
***************
*** 99,102 ****
--- 115,125 ----
 pass
 verify(not q.empty(), "Queue should not be empty")
+ q.fail_next_get = True
+ try:
+ q.get(timeout=0.1)
+ raise TestFailed("The queue didn't fail when it should have")
+ except FailingQueueException:
+ pass
+ verify(not q.empty(), "Queue should not be empty")
 q.get()
 verify(q.empty(), "Queue should be empty")
***************
*** 129,134 ****
--- 152,163 ----
 except Queue.Full:
 pass
+ try:
+ q.put("full", timeout=0.1)
+ raise TestFailed("Didn't appear to time-out with a full queue")
+ except Queue.Full:
+ pass
 # Test a blocking put
 _doBlockingTest( q.put, ("full",), q.get, ())
+ _doBlockingTest( q.put, ("full", True, 0.2), q.get, ())
 # Empty it
 for i in range(queue_size):
***************
*** 140,145 ****
--- 169,180 ----
 except Queue.Empty:
 pass
+ try:
+ q.get(timeout=0.1)
+ raise TestFailed("Didn't appear to time-out with an empty queue")
+ except Queue.Empty:
+ pass
 # Test a blocking get
 _doBlockingTest( q.get, (), q.put, ('empty',))
+ _doBlockingTest( q.get, (True, 0.2), q.put, ('empty',))
 
 def test():

AltStyle によって変換されたページ (->オリジナル) /