
    <|h                         d dl mZ d dlZd dlmZmZ dZ G d dej                        Zd Z	 G d dej                        Z
ed	k(  r ej                          yy)
    N)utilsocket皙?c                   t    e Zd Z ej                  d      d        Zd Zd Z ee	d      rd Z
d Zd Zd	 Zy
y
)Testz4Timing causes the state to often be [start,finished]c                     g fd}t        j                  |      }t        j                  t        dz         dgk(  sJ        |j	                          | j                  g d       y )Nc                      	  j                  d       t        j                  t        dz          j                  d       y #   j                  d       Y 'xY w)Nstartg      @exceptfinished)appendgeventsleepDELAY)states   U/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/tests/test__api.pytestz'Test.test_killing_dormant.<locals>.test#   sE    'W%US[)
 LL$	'X&s   -A A   r
   )r
   r   r   )r   spawnr   r   killassertEqual)selfr   gr   s      @r   test_killing_dormantzTest.test_killing_dormant   s\    	% LLUQY	!(5(!	 ?@    c                 j    d }| j                  t        j                  t        j                  d|       y )Nc                  P    t        j                  dt         j                  dd      S )Ng?r      )timeout_value)r   with_timeoutr    r   r   funcz+Test.test_nested_with_timeout.<locals>.func5   s    &&sFLL!1MMr   r   )assertRaisesr   Timeoutr    )r   r"   s     r   test_nested_with_timeoutzTest.test_nested_with_timeout4   s&    	N&..&*=*=sDIr   c                    t        j                  t        j                  t        t         j
                        d      }t        j
                  d       t        j                  |j                  d       }|j                         }t        |t              sJ |       dt        |      v sJ t        t        |                   |j                          y )Nr   r   Invalid switch)r   r   r   wrap_errorsAssertionErrorr   switchget
isinstancestrreprr   )r   pswitcherresults       r   test_sleep_invalid_switchzTest.test_sleep_invalid_switch9   s    LL)).&,,GKQ<<$/&.196913v;.AS[0AA.r   
socketpairc                    t        j                         \  }}	 t        j                  t	        j
                  t        t         j                        |j                               }t        j                         j                  j                  t        |       |t        j                  |       |j                         }t        |t              sJ |       dt!        |      v sJ t#        t!        |                   	 |j%                          |j%                          y # |j%                          |j%                          w xY w)Nr'   )r   r3   r   r   r   r(   r)   	wait_readfilenoget_hublooprun_callbackswitch_Noner   r+   r,   r-   r.   close)r   r   sock1sock2r/   r1   s         r   _test_wait_read_invalid_switchz#Test._test_wait_read_invalid_switchD   s    !,,.LE5LL!1!1.282B2B"D!&1  %%22;B$LL'!&.9A6A9'3v;6IS[8II6 s   C D "D=c                 &    | j                  d        y Nr>   r   s    r   test_invalid_switch_NonezTest.test_invalid_switch_NoneT   s    //5r   c                 &    | j                  d       y )Nr   rA   rB   s    r   test_invalid_switch_0zTest.test_invalid_switch_0W   s    //2r   c                 &    | j                  d       y )NgMbP?rA   rB   s    r   test_invalid_switch_1zTest.test_invalid_switch_1Z   s    //6r   N)__name__
__module____qualname__	greentestskipOnAppVeyorr   r%   r2   hasattrr   r>   rC   rE   rG   r!   r   r   r   r      sU    YTUA VA(J
 v|$	 	6	3	71 %r   r   c                 &    | j                  d        y r@   )r*   )r   s    r   r:   r:   `   s    HHTNr   c                       e Zd Zd Zd Zy)
TestTimersc                     dgfd}t        j                  |       | j                  dg       t        j                          t        j                  d       | j                  g        y )Nr   c                  p    t        j                  d j                         t        j                  d       y )Ng{Gz?g{Gz?)r   spawn_laterpopr   lsts   r   r"   z)TestTimers.test_timer_fired.<locals>.funci   s#    tSWW-LLr   r   )r   r   r   r   r   r"   rV   s     @r   test_timer_firedzTestTimers.test_timer_firedf   sV    c	 	Tqc" 	Sb!r   c                     dgfd}t        j                  |       t        j                  d       | j                  g        y )Nr   c                  D    t        j                   j                         y r@   )r   r   rT   rU   s   r   r"   z4TestTimers.test_spawn_is_not_cancelled.<locals>.func{   s    LL!r   r   )r   r   r   r   rW   s     @r   test_spawn_is_not_cancelledz&TestTimers.test_spawn_is_not_cancelledx   s9    c	" 	TSb!r   N)rH   rI   rJ   rX   r[   r!   r   r   rP   rP   d   s    "$"r   rP   __main__)gevent.testingtestingrK   r   r   r   r   TestCaser   r:   rP   rH   mainr!   r   r   <module>ra      sZ   , #  >79 >7F"## "> zINN r   