
    <|h{                         d dl mZ d dlZd dlmZ d dlZdZej                  sedz  Z	nedz  Z	 G d dej                        Z G d d	ej                        Zed
k(  r ej                          yy)    N)get_hubg{Gz?g       @g      4@c                       e Zd ZdZd Zd Zy)TestDirectRaiseFc                     	 t         j                  # t         j                  $ r&}|j                  rJ t        |             Y d }~y d }~ww xY wNgeventTimeoutpendingrepr)selfts     Y/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/tests/test__timeout.pytest_direct_raise_classz'TestDirectRaise.test_direct_raise_class   s<    	*.. ~~ 	*yy)$q')=y	*s    AAAc                     t        j                         }	 |# t         j                  $ r3}||u s	J ||f       |j                  rJ t        |             Y d }~y d }~ww xY wr   r   )r   timeoutr   s      r   test_direct_raise_instancez*TestDirectRaise.test_direct_raise_instance   sX    .."	*M~~ 	*a<-'1-<yy)$q')=y	*s    A)AAN)__name__
__module____qualname__switch_expectedr   r        r   r   r      s    O**r   r   c                   z    e Zd Zd Zd Zd Zd Zd Zd Zd Z	ddZ
d	 Zd
 Zd Zd Zej                   d        Zy)Testc                     	 t               j                          | j                  d       y # t        j                  $ r#}||ur |r|j                          |cY d }~S d }~ww xY wNzMust raise Timeout)r   switchfailr	   r
   close)r   r   r    exs       r   _testz
Test._test!   sR    	III*+~~ 	 
I	s   ), A"AA"A"c                     |j                          | j                  |d       |j                          | j                  |d      S )NFT)startr"   r   r   s     r   _check_expireszTest._check_expires,   s3    

7E"zz'4((r   c                 X    t        j                  t              }| j                  |       y r   r	   r
   SHOULD_EXPIREr&   r%   s     r   test_expireszTest.test_expires3   s    ../G$r   c                 Z    t        j                  t        d      }| j                  |       y )NFr(   r%   s     r   test_expires_falsezTest.test_expires_false7   s"     ..6G$r   c                     t        j                  t        d      }| j                  |      }| j	                  t        |      j                  d             y NXXX)r	   r
   r)   r&   
assertTruestrendswithr   r   r!   s      r   test_expires_strzTest.test_expires_str=   s?     ..6  )B((/0r   c                 n    | j                  dt        |      v xs dt        |      v t        |             y )Nzexceptions must bezexceptions must derive)r0   r1   )r   r!   s     r   assert_type_errzTest.assert_type_errD   s3    ,B7^;SWZ[]W^;^`cdf`ghr   c                 (   t        j                  t        t                     }|j	                          	 t               j                          | j                  d       |j                           G d d      }t        j                  t        |      }|j	                          	 t               j                          | j                  d       |j                          t        j                  t         |             }|j	                          	 t               j                          | j                  d       |j                          y # t        $ r}| j                  |       Y d }~d }~ww xY w# t        $ r;}| j                  t        j                  d       | j                  |       Y d }~d }~w | j                  t        j                  d       t        j                          d   }| j#                  ||       Y 2xY w# t        $ r<}| j                  t        j                  d       | j                  |       Y d }~d }~w | j                  t        j                  d       t        j                          d   }| j#                  ||       Y ]xY w)NzMost raise TypeErrorc                       e Zd Zy)1Test.test_expires_non_exception.<locals>.OldStyleN)r   r   r   r   r   r   OldStyler9   R   s    r   r:   zMust raise OldStylez-Py3 raises a TypeError for non-BaseExceptionsz+Old style classes can only be raised on Py2r   )r	   r
   r)   objectr$   r   r   r   	TypeErrorr6   r    r0   	greentestPY3PY2sysexc_infoassertEqual)r   r   r!   r:   r   s        r   test_expires_non_exceptionzTest.test_expires_non_exceptionH   s   ..9	%III,- 		 	..9		*III+, 	..
;		*III+, 	A  	%  $$	%  	%OOIMM+Z[  $$	*OOIMM+XYq!AQ)  	%OOIMM+Z[  $$	*OOIMM+XYq!AQ)sI   )E ")E- )H  	E*E%%E*-	G=61F,,AG= 	J	1I  AJc                     	 |5  t               j                          d d d        |r| j	                  d       y y # 1 sw Y   xY w# t        j                  $ r}||ur |cY d }~S d }~ww xY wr   )r   r   r	   r
   r   )r   r   raisesr!   s       r   _check_context_manager_expiresz#Test._check_context_manager_expiresp   sg    	 #	  "# II*+ # #~~ 	 I	s0   A :A AA A*A%A*%A*c                 X    t        j                  t              }| j                  |       y r   )r	   r
   r)   rF   r%   s     r   test_context_managerzTest.test_context_manager|   s    ../++G4r   c                     t        j                  t        d      }| j                  |d       | j	                  t        |      j                  d      t        |             y )NF)rE   z(silent)r	   r
   r)   rF   r0   r1   r2   r%   s     r   test_context_manager_falsezTest.test_context_manager_false   sF    ..6++GE+BG--j93w<Hr   c                     t        j                  t        d      }| j                  |      }| j	                  t        |      j                  d      t        |             y r.   rJ   r3   s      r   test_context_manager_strzTest.test_context_manager_str   sC    ..6009B((/R9r   c                     t        j                  t              }|j                          |j	                          t        j
                  t               | j                  |j                  |       |j                          y r   )
r	   r
   r)   r$   cancelsleepSHOULD_NOT_EXPIREassertFalser   r    r%   s     r   test_cancelzTest.test_cancel   sM    ../&''2r   c                    | j                  t        j                        5  t        j                  t        t        j
                  t               d d d        t               }t        j                  t        t        j
                  t        |      }| j                  ||       t        j                  t        t        j
                  t        |      }| j                  |       y # 1 sw Y   xY w)N)timeout_value)
assertRaisesr	   r
   with_timeoutr)   rP   rQ   r;   assertIsassertIsNone)r   Xrs      r   test_with_timeoutzTest.test_with_timeout   s    v~~. 	Pv||=NO	PHv||=N^_`a 16<<^_`!	P 	Ps   .C""C+N)T)r   r   r   r"   r&   r*   r,   r4   r6   rC   rF   rH   rK   rM   rS   r=   ignores_leakcheckr\   r   r   r   r   r      s[    	)%%1i&P
,5I:
    !r   r   __main__)gevent.testingtestingr=   r	   
gevent.hubr   r@   r)   RUNNING_ON_CIrQ   TestCaser   r   r   mainr   r   r   <module>re      sw    "   
%+%,*i(( *$|9 |~ zINN r   