ó
ÐH/\c           @   s   d  d l  j Z d  d l Z d  d l m Z m Z d Z d e j f d „  ƒ  YZ d „  Z	 d e j f d „  ƒ  YZ
 e d	 k r‹ e j ƒ  n  d S(
   iÿÿÿÿN(   t   utilt   socketgš™™™™™¹?t   Testc           B   sh   e  Z e j d  ƒ d „  ƒ Z d „  Z d „  Z e e d ƒ rf d „  Z	 d „  Z
 d „  Z d „  Z n  RS(	   s4   Timing causes the state to often be [start,finished]c            sw   g  ‰  ‡  f d †  } t  j | ƒ } t  j t d ƒ ˆ  d g k sP t ˆ  ƒ ‚ | j ƒ  |  j ˆ  d d d g ƒ d  S(   Nc              sJ   y" ˆ  j  d ƒ t j t d ƒ Wn ˆ  j  d ƒ n Xˆ  j  d ƒ d  S(   Nt   startg      @t   exceptt   finished(   t   appendt   geventt   sleept   DELAY(    (   t   state(    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test#   s    i   R   R   R   (   R   t   spawnR   R	   t   AssertionErrort   killt   assertEqual(   t   selfR   t   g(    (   R
   s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_killing_dormant   s    

c         C   s)   d „  } |  j  t j t j d | ƒ d  S(   Nc           S   s   t  j d t  j d d d ƒS(   Ngš™™™™™É?i   t   timeout_valuei   (   R   t   with_timeoutR   (    (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   func5   s    gš™™™™™¹?(   t   assertRaisesR   t   TimeoutR   (   R   R   (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_nested_with_timeout4   s    	c         C   s¢   t  j t j t t  j ƒ d ƒ } t  j d ƒ t  j | j d  ƒ } | j ƒ  } t	 | t ƒ sj t | ƒ ‚ d t
 | ƒ k s” t t t
 | ƒ ƒ ƒ ‚ | j ƒ  d  S(   Ni   i    s   Invalid switch(   R   R   R    t   wrap_errorsR   R   t   switcht   Nonet   gett
   isinstancet   strt   reprR   (   R   t   pt   switchert   result(    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_sleep_invalid_switch9   s    !*t
   socketpairc         C   sß   t  j ƒ  \ } } z± t j t j t t  j ƒ | j ƒ  ƒ } t j	 ƒ  j
 j t | ƒ | d  k	 rq t j | ƒ n  | j ƒ  } t | t ƒ s˜ t | ƒ ‚ d t | ƒ k sÂ t t t | ƒ ƒ ƒ ‚ Wd  | j ƒ  | j ƒ  Xd  S(   Ns   Invalid switch(   R   R$   R   R   R    R   R   t	   wait_readt   filenot   get_hubt   loopt   run_callbackt   switch_NoneR   R   R   R   R   R   t   close(   R   R   t   sock1t   sock2R    R"   (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   _test_wait_read_invalid_switchD   s    	.
c         C   s   |  j  d  ƒ d  S(   N(   R.   R   (   R   (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_invalid_switch_NoneT   s    c         C   s   |  j  d ƒ d  S(   Ni    (   R.   (   R   (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_invalid_switch_0W   s    c         C   s   |  j  d ƒ d  S(   Ngü©ñÒMbP?(   R.   (   R   (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_invalid_switch_1Z   s    (   t   __name__t
   __module__t	   greentestt   skipOnAppVeyorR   R   R#   t   hasattrR   R.   R/   R0   R1   (    (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyR      s   						c         C   s   |  j  d  ƒ d  S(   N(   R   R   (   R   (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyR*   `   s    t
   TestTimersc           B   s   e  Z d  „  Z d „  Z RS(   c            sc   d g ‰  ‡  f d †  } t  j | ƒ |  j ˆ  d g ƒ t  j ƒ  t  j d ƒ |  j ˆ  g  ƒ d  S(   Ni   c              s$   t  j d ˆ  j ƒ t  j d ƒ d  S(   Ng{®Gáz„?g{®Gáz”?(   R   t   spawn_latert   popR   (    (   t   lst(    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyR   i   s    gš™™™™™¹?(   R   R   R   R   (   R   R   (    (   R:   s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_timer_firedf   s    	
c            sF   d g ‰  ‡  f d †  } t  j | ƒ t  j d ƒ |  j ˆ  g  ƒ d  S(   Ni   c              s   t  j ˆ  j ƒ d  S(   N(   R   R   R9   (    (   R:   (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyR   {   s    gš™™™™™¹?(   R   R   R   R   (   R   R   (    (   R:   s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   test_spawn_is_not_cancelledx   s
    	(   R2   R3   R;   R<   (    (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyR7   d   s   	t   __main__(   t   gevent.testingt   testingR4   R   R    R   R	   t   TestCaseR   R*   R7   R2   t   main(    (    (    s5   lib/python2.7/site-packages/gevent/tests/test__api.pyt   <module>   s   C	