ó
‹wÛjc           @   sM  d  d l  Z  d  d l Z d  d l Z d  d l m Z e j d ƒ Z d Z d e j f d „  ƒ  YZ	 d d d „  ƒ  YZ
 d	 e
 f d
 „  ƒ  YZ d e e j f d „  ƒ  YZ d e e j f d „  ƒ  YZ d e e j f d „  ƒ  YZ d e f d „  ƒ  YZ d e  j  f d „  ƒ  YZ d e
 e j f d „  ƒ  YZ d „  Z e d k rIe ƒ  n  d S(   iÿÿÿÿN(   t   test_supportt	   threadingi   t   _TriggerThreadc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s5   | |  _  | |  _ t j ƒ  |  _ t j j |  ƒ d  S(   N(   t   fnt   argsR   t   Eventt   startedEventt   Threadt   __init__(   t   selfR   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyR      s    		c         C   s.   t  j d ƒ |  j j ƒ  |  j |  j Œ  d  S(   Ngš™™™™™¹?(   t   timet   sleepR   t   setR   R   (   R	   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   run   s    	(   t   __name__t
   __module__R   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyR      s   	t   BlockingTestMixinc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   d  |  _ d  S(   N(   t   Nonet   t(   R	   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   tearDown.   s    c         C   sŽ   t  | | ƒ |  _ |  j j ƒ  | | Œ  |  _ |  j j j ƒ  sT |  j d | ƒ n  |  j j d ƒ |  j j ƒ  r‡ |  j d | ƒ n  |  j S(   Ns,   blocking function '%r' appeared not to blocki
   s,   trigger function '%r' appeared to not return(	   R   R   t   startt   resultR   t   is_sett   failt   joint   is_alive(   R	   t
   block_funct
   block_argst   trigger_funct   trigger_args(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   do_blocking_test1   s    		c         C   s¶   t  | | ƒ |  _ |  j j ƒ  z: y | | Œ  Wn | k
 rF ‚  n X|  j d | ƒ Wd  |  j j d ƒ |  j j ƒ  r� |  j d | ƒ n  |  j j j ƒ  s± |  j 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   R   (   R	   R   R   R   R   t   expected_exception_class(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   do_exceptional_blocking_test@   s    		(   R   R   R   R   R    (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyR   ,   s   		t   BaseQueueTestc           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   d |  _  t j ƒ  |  _ d  S(   Ni    (   t   cumR   t   Lockt   cumlock(   R	   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   setUpV   s    	c      	   C   sã  | j  ƒ  s t d ‚ n  | j d ƒ | j d ƒ | j d ƒ t d d d d g d d d d g d d d d g ƒ } | j ƒ  | j ƒ  | j ƒ  g } |  j | | | j j d ƒ x< t t	 d	 ƒ D]* } | j | ƒ |  j
 | j  ƒ  d
 ƒ qÄ W|  j
 | j ƒ  d ƒ d t	 } d t	 } | j | ƒ |  j
 | j ƒ  d ƒ y$ | j | d d ƒ|  j d ƒ Wn t j k
 rzn Xy$ | j | d d ƒ|  j d ƒ Wn t j k
 rµn X|  j | j | f | j d ƒ |  j | j | t d f | j d ƒ x t t	 ƒ D] } | j ƒ  qW|  j
 | j  ƒ  d ƒ y! | j d d ƒ |  j d ƒ Wn t j k
 rhn Xy! | j d d ƒ |  j d ƒ Wn t j k
 r n X|  j | j d | j d ƒ |  j | j t d f | j d ƒ d  S(    Ns&   Call this function with an empty queueio   iM  iÞ   t   Queuet	   LifoQueuet   PriorityQueues&   Didn't seem to queue the correct data!i   s   Queue should not be emptys   Queue should not be fulli   i   s   Queue should be fullt   blocki    s(   Didn't appear to block with a full queuet   timeoutg{®Gáz„?s+   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 queuet   emptyi   (    (    (    (   R+   (   R+   (   R+   t   RuntimeErrort   putt   dictt   gett   assertEqualt	   __class__R   t   ranget
   QUEUE_SIZEt
   assertTruet   fullR   R&   t   FullR   t   Truet   Empty(   R	   t   qt   target_ordert   actual_ordert   it   lastR5   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   simple_queue_testZ   s\    !

%c         C   s`   xY t  r[ | j ƒ  } | d  k r/ | j ƒ  d  S|  j � |  j | 7_ Wd  QX| j ƒ  q Wd  S(   N(   R7   R/   R   t	   task_doneR$   R"   (   R	   R9   t   x(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   worker�   s    	

c         C   s¸   d |  _  x0 d D]( } t j d |  j d | f ƒ j ƒ  q Wx! t d ƒ D] } | j | ƒ qI W| j ƒ  |  j |  j  t	 t
 d ƒ ƒ d ƒ x d D] } | j d  ƒ q“ W| j ƒ  d  S(	   Ni    i   t   targetR   id   s0   q.join() did not block until all tasks were done(   i    i   (   i    i   (   R"   R   R   RA   R   t   xrangeR-   R   R0   t   sumR2   R   (   R	   R9   R<   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   queue_join_test™   s    	&
c         C   s?   |  j  ƒ  } y | j ƒ  Wn t k
 r- n X|  j d ƒ d  S(   Ns(   Did not detect task count going negative(   t	   type2testR?   t
   ValueErrorR   (   R	   R9   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   test_queue_task_done¦   s    c         C   sY   |  j  ƒ  } |  j | ƒ |  j | ƒ y | j ƒ  Wn t k
 rG n X|  j d ƒ d  S(   Ns(   Did not detect task count going negative(   RF   RE   R?   RG   R   (   R	   R9   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   test_queue_join°   s    c         C   s-   |  j  t ƒ } |  j | ƒ |  j | ƒ d  S(   N(   RF   R3   R>   (   R	   R9   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   test_simple_queue½   s    (	   R   R   R%   R>   RA   RE   RH   RI   RJ   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyR!   U   s   		5	
		
	t	   QueueTestc           B   s   e  Z e j Z RS(    (   R   R   R&   RF   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRK   Å   s   t   LifoQueueTestc           B   s   e  Z e j Z RS(    (   R   R   R&   R'   RF   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRL   È   s   t   PriorityQueueTestc           B   s   e  Z e j Z RS(    (   R   R   R&   R(   RF   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRM   Ë   s   t   FailingQueueExceptionc           B   s   e  Z RS(    (   R   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRN   Ñ   s   t   FailingQueuec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         G   s)   t  |  _ t  |  _ t j j |  | Œ d  S(   N(   t   Falset   fail_next_putt   fail_next_getR&   R   (   R	   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyR   Õ   s    		c         C   s1   |  j  r t |  _  t d ‚ n  t j j |  | ƒ S(   Ns   You Lose(   RQ   RP   RN   R&   t   _put(   R	   t   item(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRS   Ù   s    		c         C   s.   |  j  r t |  _  t d ‚ n  t j j |  ƒ S(   Ns   You Lose(   RR   RP   RN   R&   t   _get(   R	   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRU   Þ   s    		(   R   R   R   RS   RU   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRO   Ô   s   		t   FailingQueueTestc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s¥  | j  ƒ  s t d ‚ n  x% t t d ƒ D] } | j | ƒ q) Wt | _ y$ | j d d d ƒ|  j d ƒ Wn t k
 r€ n Xt | _ y$ | j d d d ƒ|  j d ƒ Wn t k
 rÁ n X| j d	 ƒ |  j	 | j
 ƒ  d
 ƒ t | _ y- |  j | j d | j d ƒ |  j d ƒ Wn t k
 r.n X| j d	 ƒ t | _ y9 |  j | j d t d f | j d t ƒ |  j d ƒ Wn t k
 r‘n X| j d	 ƒ |  j	 | j
 ƒ  d
 ƒ | j ƒ  |  j	 | j
 ƒ  d ƒ | j d	 ƒ |  j	 | j
 ƒ  d
 ƒ |  j | j d | j d ƒ x t t ƒ D] } | j ƒ  q"W|  j	 | j  ƒ  d ƒ | j d ƒ t | _ y | j ƒ  |  j d ƒ Wn t k
 r�n X|  j	 | j  ƒ  d ƒ t | _ y! | j d d ƒ |  j d ƒ Wn t k
 rån X|  j	 | j  ƒ  d ƒ | j ƒ  |  j	 | j  ƒ  d ƒ t | _ y0 |  j | j d | j d t ƒ |  j d ƒ Wn t k
 rin X|  j	 | j  ƒ  d ƒ | j ƒ  |  j	 | j  ƒ  d ƒ d  S(   Ns&   Call this function with an empty queuei   t   oopsR)   i    s)   The queue didn't fail when it should haveR*   gš™™™™™¹?R=   s   Queue should be fullR5   i
   s   Queue should not be fulls   Queue should be emptyt   firsts   Queue should not be emptyR+   (   R5   (    (    (   R5   (    (    (   R+   (   R+   R,   R2   R3   R-   R7   RQ   R   RN   R4   R5   R   R/   R    RR   (   R	   R9   R<   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   failing_queue_testæ   sŠ    				!
	
	
	
c         C   s*   t  t ƒ } |  j | ƒ |  j | ƒ d  S(   N(   RO   R3   RY   (   R	   R9   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   test_failing_queue7  s    (   R   R   RY   RZ   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyRV   ä   s   	Qc           C   s   t  j t t t t ƒ d  S(   N(   R    t   run_unittestRK   RL   RM   RV   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt	   test_main?  s    t   __main__(    (   R&   R
   t   unittestt   testR    t   import_moduleR   R3   R   R   R   R!   t   TestCaseRK   RL   RM   t	   ExceptionRN   RO   RV   R\   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_queue.pyt   <module>   s"    )p[	