mς
­fIc           @   sΓ   d  k  Z  d  k Z d  k Z d  k Z d k l Z l Z l Z d Z d e i	 f d     YZ
 d   Z d   Z d e f d     YZ d	 e  i  f d
     YZ d   Z d   Z d   Z e   d  S(   N(   s   verifys
   TestFaileds   verbosei   t   _TriggerThreadc           B   s   t  Z d   Z d   Z RS(   Nc         C   s5   | |  _  | |  _ t i   |  _ t i i |   d  S(   N(   t   fnt   selft   argst	   threadingt   Eventt   startedEventt   Threadt   __init__(   R   R   R   (    (    t,   /mit/python/lib/python2.4/test/test_queue.pyR      s    		c         C   s.   t  i d  |  i i   |  i |  i   d  S(   Nf0.10000000000000001(   t   timet   sleepR   R   t   setR   R   (   R   (    (    R	   t   run   s    	(   t   __name__t
   __module__R   R   (    (    (    R	   R       s   	c         C   s{   t  | |  } | i   |  |   } | i i	   p t
 d |    n | i d  | i   o t
 d |   n | S(   Ns,   blocking function '%r' appeared not to blocki
   s,   trigger function '%r' appeared to not return(   R    t   trigger_funct   trigger_argst   tt   startt
   block_funct
   block_argst   resultR   t   isSett
   TestFailedt   joint   isAlive(   R   R   R   R   R   R   (    (    R	   t   _doBlockingTest+   s    
c         C   sͺ   t  | |  } | i   z; y |  |   Wn | j
 o
   n Xt d |   Wd  | i	 d  | i
   o t d |   n | i i   p t d   n Xd  S(   Ns   expected exception of kind %ri
   s,   trigger function '%r' appeared to not returns(   trigger thread ended but event never set(   R    R   R   R   R   R   R   t   expected_exception_classR   R   R   R   R   (   R   R   R   R   R   R   (    (    R	   t   _doExceptionalBlockingTest:   s    
 t   FailingQueueExceptionc           B   s   t  Z RS(   N(   R   R   (    (    (    R	   R   O   s   t   FailingQueuec           B   s#   t  Z d   Z d   Z d   Z RS(   Nc         G   s)   t  |  _ t  |  _ t i i |  |  d  S(   N(   t   FalseR   t   fail_next_putt   fail_next_gett   QueueR   R   (   R   R   (    (    R	   R   S   s    		c         C   s3   |  i o t |  _ t d  n t i i |  |  S(   Ns   You Lose(   R   R!   R    R   R#   t   _putt   item(   R   R%   (    (    R	   R$   W   s    
	c         C   s0   |  i o t |  _ t d  n t i i |   S(   Ns   You Lose(   R   R"   R    R   R#   t   _get(   R   (    (    R	   R&   \   s    
	(   R   R   R   R$   R&   (    (    (    R	   R   R   s   		c         C   s  |  i   p t d  n x% t t d  D] } |  i |  q+ Wt |  _ y# |  i d d d t	 d   Wn t
 j
 o n Xt |  _ y# |  i d d d t	 d   Wn t
 j
 o n X|  i d	  t |  i   d
  t |  _ y) t |  i d |  i f   t	 d   Wn t
 j
 o n X|  i d	  t |  _ y5 t |  i d t d f |  i f  t
  t	 d   Wn t
 j
 o n X|  i d	  t |  i   d
  |  i   t |  i   d  |  i d	  t |  i   d
  t |  i d |  i f   x t t  D] } |  i   qWt |  i   d  |  i d  t |  _ y |  i   t	 d   Wn t
 j
 o n Xt |  i   d  t |  _ y  |  i d d  t	 d   Wn t
 j
 o n Xt |  i   d  |  i   t |  i   d  t |  _ y, t |  i f  |  i d t
  t	 d   Wn t
 j
 o n Xt |  i   d  |  i   t |  i   d  d  S(   Ns&   Call this function with an empty queuei   t   oopst   blocki    s)   The queue didn't fail when it should havet   timeoutf0.10000000000000001t   lasts   Queue should be fullt   fulli
   s   Queue should not be fulls   Queue should be emptyt   firsts   Queue should not be emptyt   empty(   s   full(   s   full(   s   empty(   t   qR-   t   RuntimeErrort   ranget
   QUEUE_SIZEt   it   putt   TrueR!   R   R   t   verifyR+   R   t   getR   R"   (   R.   R2   (    (    R	   t   FailingQueueTestb   s     				
 	
	
	
c         C   se  |  i   p t d  n |  i d  |  i d  t |  i   d j o |  i   d j d  x9 t t d  D]' } |  i |  t |  i   d  qq Wt |  i	   d  |  i d  t |  i	   d	  y# |  i d
 d d t
 d   Wn t i j
 o n Xy# |  i d
 d d t
 d   Wn t i j
 o n Xt |  i d |  i f   t |  i d
 t d f |  i f   x t t  D] } |  i   qWt |  i   d  y  |  i d d  t
 d   Wn t i j
 o n Xy  |  i d d  t
 d   Wn t i j
 o n Xt |  i f  |  i d  t |  i t d f |  i d  d  S(   Ns&   Call this function with an empty queueio   iή   s&   Didn't seem to queue the correct data!i   s   Queue should not be emptys   Queue should not be fullR*   s   Queue should be fullR+   R(   i    s(   Didn't appear to block with a full queueR)   f0.01s+   Didn't appear to time-out with a full queuei
   s   Queue should be emptys*   Didn't appear to block with an empty queues-   Didn't appear to time-out with an empty queueR-   (   s   full(   s   empty(   s   empty(   R.   R-   R/   R3   R5   R6   R0   R1   R2   R+   R   R#   t   FullR   R4   t   Empty(   R.   R2   (    (    R	   t   SimpleQueueTest³   sR    % " c          C   sg   t  i  t  }  t |   t |   t o	 d GHn t t  }  t |   t |   t o	 d GHn d  S(   Ns!   Simple Queue tests seemed to works"   Failing Queue tests seemed to work(   R#   R1   R.   R:   t   verboseR   R7   (   R.   (    (    R	   t   testΰ   s    

	

(   R#   t   sysR   R
   t   test.test_supportR5   R   R;   R1   R   R    R   R   t	   ExceptionR   R   R7   R:   R<   (   R=   R;   R1   R5   R   R:   R   R#   R   R   R
   R<   R   R   R7   R    (    (    R	   t   ?   s   							Q	-	