ó
ŠwÛjc           @€  sq  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z	 y d  d l
 Z
 d  d l Z Wn e k
 r— d Z
 d Z n Xe	 j d ƒ Z d e j f d „  ƒ  YZ e j e d ƒ d e j f d	 „  ƒ  Yƒ Z d
 e j f d „  ƒ  YZ e j e oe
 d ƒ d e j f d „  ƒ  Yƒ Z d e j f d „  ƒ  YZ d „  Z e d k rme ƒ  n  d S(   iÿÿÿÿ(   t   with_statementN(   t   test_supportt	   _testcapit   CAPITestc           B€  s   e  Z d  „  Z RS(   c         C€  s   t  j ƒ  d  S(   N(   R   t   test_buildvalue_N(   t   self(    (    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_capi.pyR      s    (   t   __name__t
   __module__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_capi.pyR      s   s!   Threading required for this test.t   TestPendingCallsc           B€  s8   e  Z d  „  Z d d „ Z d „  Z d „  Z d „  Z RS(   c         €  sa   ‡  f d †  } xK t  | ƒ D]= } t j t j ƒ  d ƒ x t rX t j | ƒ r< Pq< q< Wq Wd  S(   Nc           €  s   ˆ  j  d  ƒ d  S(   N(   t   appendt   None(    (   t   l(    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_capi.pyt   callback   s    g{®Gáz”?(   t   ranget   timet   sleept   randomt   TrueR   t   _pending_threadfunc(   R   R   t   nR   t   i(    (   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_capi.pyt   pendingcalls_submit   s    	c         C€  s×   d } x¦ t  | ƒ | k r® t r> t j r> d t  | ƒ f Gn  x t d ƒ D] } | | } qK W| r{ | j j ƒ  r{ q	 n  | d 7} |  j | d k  d | t  | ƒ f ƒ q	 Wt rÓ t j rÓ d t  | ƒ f GHn  d  S(   Ni    s   (%i)iè  i   i'  s(   timeout waiting for %i callbacks, got %i(   t   lent   Falset   supportt   verboset   xranget   eventt   is_sett
   assertTrue(   R   R   R   t   contextt   countR   t   a(    (    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_capi.pyt   pendingcalls_wait,   s    
c         C€  sÞ   d } g  } d t  f d „  ƒ  Y} | ƒ  } g  | _ d | _ | | j | _ d | _ t j ƒ  | _ t j ƒ  | _	 g  t
 | j ƒ D]$ } t j d |  j d | f ƒ ^ q„ } t j | ƒ � |  j | j | | ƒ Wd  QXd  S(   Ni    t   fooc           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_capi.pyR"   C   s    i   i    t   targett   args(   t   objectR   R   t   nThreadst	   nFinishedt	   threadingt   Lockt   lockt   EventR   R   t   Threadt   pendingcalls_threadR   t   start_threadsR!   (   R   R   t   threadsR"   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_capi.pyt   test_pendingcalls_threaded?   s    				7c      
   C€  s„   z |  j  | j | j ƒ Wd  | j �8 | j d 7_ | j } t rZ t j rZ d G| GHn  Wd  QX| | j k r | j	 j
 ƒ  n  Xd  S(   Ni   s   finished threads: (   R   R   R   R*   R'   R   R   R   R&   R   t   set(   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_capi.pyR-   R   s    
	c         C€  s0   g  } d } |  j  | | ƒ |  j | | ƒ d  S(   Ni@   (   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_capi.pyt   test_pendingcalls_non_threaded^   s    N(   R   R   R   R
   R!   R0   R-   R2   (    (    (    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_capi.pyR      s
   			t   TestGetIndicesc           B€  s   e  Z d  „  Z RS(   c         C€  sD  |  j  t j t d d d ƒ d ƒ d ƒ |  j  t j t d d d ƒ d ƒ d  ƒ |  j  t j t d d d ƒ d ƒ d ƒ |  j  t j t d d	 d ƒ d ƒ d  ƒ |  j  t j t d d d
 ƒ d ƒ d ƒ |  j  t j t d d d
 ƒ d ƒ d  ƒ |  j  t j t d d d
 ƒ d ƒ d ƒ |  j  t j t d d	 d
 ƒ d ƒ d  ƒ d  S(   Nl   
 i   i   id   i    i
   g333333$@l    gš™™™™4@l    (   i    i
   i   i   (   i    i
   i   i   (   i    i
   i   i   (   i    i
   i   i   (   t   assertEqualR   t   get_indicest   sliceR
   (   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_capi.pyt   test_get_indicesk   s    ((((((((   R   R   R7   (    (    (    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_capi.pyR3   i   s   t   TestThreadStatec           B€  s   e  Z e j d  „  ƒ Z RS(   c         €  s@   ‡  f d †  } | ƒ  t  j d | ƒ } | j ƒ  | j ƒ  d  S(   Nc          €  s_   g  ‰  ‡  f d †  }  t  j |  ƒ |  } } t j d ƒ ˆ j ˆ  j t j ƒ  ƒ d d ƒ d  S(   Nc           €  s   ˆ  j  t j ƒ  ƒ d  S(   N(   R	   t   threadt	   get_ident(    (   t   idents(    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_capi.pyR   €   s    i   i   s/   Couldn't find main thread correctly in the list(   R   t   _test_thread_stateR   R   R4   R   R9   R:   (   R   R    t   b(   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_capi.pyR#   }   s    
R#   (   R(   R,   t   startt   join(   R   R#   t   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_capi.pyt   test_thread_statez   s
    
(   R   R   R   t   reap_threadsRA   (    (    (    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_capi.pyR8   w   s   t   Test_testcapic           B€  s(   e  Z e ƒ  j d  „  e e ƒ Dƒ ƒ RS(   c         c€  sC   |  ]9 } | j  d  ƒ r | j d ƒ r | t t | ƒ f Vq d S(   t   test_t   _codeN(   t
   startswitht   endswitht   getattrR   (   t   .0t   name(    (    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_capi.pys	   <genexpr>‘   s   (   R   R   t   localst   updatet   dirR   (    (    (    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_capi.pyRC   �   s   c           C€  s   t  j t t t t t ƒ d  S(   N(   R   t   run_unittestR   R   R8   R3   RC   (    (    (    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_capi.pyt	   test_main–   s    t   __main__(   t
   __future__R    t   stringt   sysR   R   t   unittestt   testR   R   R9   R(   t   ImportErrorR
   t   import_moduleR   t   TestCaseR   t
   skipUnlessR   R3   R8   RC   RO   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_capi.pyt   <module>   s.   
N	