
     nh1                       d dl mZ d dlZd dlZd dlmZmZ er
d dlmZm	Z	m
Z
 d dlZd dlZd dlmZmZ ddlmZ ddlmZmZ dd	lmZmZmZmZmZmZmZmZmZ dd
lm Z  ej!        dk     rd dl"m#Z#m$Z$ erd dlmZ  ed          Z%ddZ&ddZ'ddZ(ej)        *                    d          dd            Z+ddZ,ddZ-ddZ.ddZ/ddZ0dS )    )annotationsN)TYPE_CHECKINGTypeVar)AsyncGenerator	Coroutine	Generator)MatcherRaisesGroup   )_core)!create_asyncio_future_in_new_loop'ignore_coroutine_never_awaited_warnings)	ConflictDetectorMultipleExceptionErrorNoPublicConstructorcoroutine_or_errorfinalfixup_module_metadatageneric_functionis_main_thread!raise_single_exception_from_groupwait_all_tasks_blocked      )BaseExceptionGroupExceptionGroup)r   TreturnNonec                   K   t          d          t          d          } 5  | 5  t          d           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        t          j        d          5  5  5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   dfd}t          t          t          j        d                    5  t	          j                    4 d {V }|	                    |           |	                    |           d d d           d {V  n# 1 d {V swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nul1ul2okmatchr    r!   c                 j   K    5  t                       d {V  d d d            d S # 1 swxY w Y   d S Nr   )r#   s   i/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/trio/_tests/test_util.pywait_with_ul1z,test_ConflictDetector.<locals>.wait_with_ul16   s       	+ 	+(*********	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   (,,r    r!   )
r   printpytestraisesr   BusyResourceErrorr
   r	   open_nursery
start_soon)r$   r+   nurseryr#   s      @r*   test_ConflictDetectorr4   )   s     
5
!
!C
5
!
!C	   	 	$KKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	               
u.e	<	<	<   	 	                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	              
+ + + + + + 
WU4e<<	=	= . .%'' 	. 	. 	. 	. 	. 	. 	.7}---}---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.. . . . . . . . . . . . . . . . . .s   AAAA	A
A	AA!ACB0BB0BB0 B!B0$C0B4	4C7B4	8CCC?E4+EE4
E 	 E4#E 	$E44E8;E8c                    dd l } dd l} | j        j        dk    sJ | j        j        dk    sJ | j        j        j        dk    sJ | j        j        j        dk    sJ | j	        j
        j        dk    sJ | j        j        j        j        dk    sJ | j        j        j        j        dk    sJ | j        j        dk    sJ | j        j        dk    sJ | j        j        j        j        dk    sJ | j        j        j        j        dk    sJ | j        j        d	k    sJ | j        j        j        d
k    sJ | j        j        j        d
k    sJ d S )Nr   trioztrio.abcztrio.lowlevelztrio.testing	Cancelledsend_allzSendStream.send_allztrio.to_threadrun_sync)r6   trio.testingr7   
__module__r1   abcStreamlowlevelwait_task_rescheduledtesting	trio_test
ParkingLot__init__r8   __name____qualname__
SendStream	to_threadr9   )r6   s    r*    test_module_metadata_is_fixed_uprH   @   s}   KKK>$....'611118?%3333=.9_LLLL<!,>>>> =#,7?JJJJ8?#.*<<<< >"k1111>&+55558'0J>>>>8'48MMMMM>"&66666>"+z9999>"/:======    c                 |   K   t                      sJ dd} t          j                            |            d {V  d S )Nr    r!   c                 &    t                      rJ d S r)   )r    rI   r*   not_main_threadz,test_is_main_thread.<locals>.not_main_thread[   s    !#######rI   r,   )r   r6   rG   r9   )rM   s    r*   test_is_main_threadrN   X   s\      $ $ $ $ .
!
!/
2
2222222222rI   z(ignore:.*@coroutine.*:DeprecationWarningc                     G d d          t                      5  dd} t          j        t                    5 }t	           |                        d d d            n# 1 swxY w Y   dt          |j                  v sJ dd lt          j	        dk     rsj
        dfd
            }t          j        t                    5 }t	           |                       d d d            n# 1 swxY w Y   dt          |j                  v sJ t          j        t                    5 }t	          t                                 d d d            n# 1 swxY w Y   dt          |j                  v sJ t          j        t                    5 }t	          t                     d d d            n# 1 swxY w Y   dt          |j                  v sJ t          j        t                    5 }t	                                  d d d            n# 1 swxY w Y   dt          |j                  v sJ t          j        t                    5 }t	          fd           d d d            n# 1 swxY w Y   dt          |j                  v sJ t          j        t                    5 }t	          t          g dg           d d d            n# 1 swxY w Y   dt          |j                  v sJ dd}t          j        t                    5 }t	          |dg           d d d            n# 1 swxY w Y   d}|t          |j                  v sJ ~d d d            d S # 1 swxY w Y   d S )Nc                      e Zd ZdZdS ))test_coroutine_or_error.<locals>.DeferredzJust kiddingN)rD   r;   rE   __doc__rL   rI   r*   DeferredrQ   d   s        rI   rS   r    r!   c                 
   K   d S r)   rL   rL   rI   r*   fz"test_coroutine_or_error.<locals>.fi   s      DrI   zexpecting an async functionr   r   2Generator[Coroutine[None, None, None], None, None]c               3  B   K                         d          E d {V  d S )N   )sleep)asyncios   r*   generator_based_coroz5test_coroutine_or_error.<locals>.generator_based_corot   s3       #==+++++++++++rI   rZ   twistedc                                   S r)   rL   )rS   s   r*   <lambda>z)test_coroutine_or_error.<locals>.<lambda>   s    xxzz rI   )rX   r   r   zappears to be synchronous_objectAsyncGenerator[None, None]c                  K   d W V  d S r)   rL   )r_   s    r*   	async_genz*test_coroutine_or_error.<locals>.async_gen   s       EEEEEErI   z5expected an async function but got an async generatorr,   )r    rV   )r_   r`   r    ra   )r   r.   r/   	TypeErrorr   strvaluerZ   sysversion_info	coroutiner   len)rU   excinfor[   rc   msgrS   rZ   s        @@r*   test_coroutine_or_errorrm   b   s           
1	2	2 8 8	 	 	 	 ]9%% 	$qqss###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$,GM0B0BBBBBg%%, , , , , ,
 y)) ;W"#7#7#9#9:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;GM 2 22222]9%% 	D@BBCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	DC...... ]9%% 	B@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	BC......]9%% 	+xxzz***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+C......]9%% 	31111222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3C......]9%% 	1sYYYK000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 +c'-.@.@@@@@	 	 	 	
 ]9%% 	/y1#...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/Ec'-(((((( q8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s1  MA M A$	$M'A$	(AMC'M'C+	+M.C+	/4M#E?ME	ME	4MF(M(F,	,M/F,	04M$H<MH	MH	4MI#M#I'	'M*I'	+4MK8MK	MK	8ML"M"L&	&M)L&	*MMMc                 J   t           d	d            } | | t                   cxu r| t          t          f         u sn J  | d           | t                   d          cxk    rdk    sn J | j        dk    sJ | j        dk    sJ | j        dk    sJ | j        t
          k    sJ d S )
Nargr   r    c                    | S )Look, a docstring!rL   )ro   s    r*   	test_funcz(test_generic_function.<locals>.test_func   s	     
rI   *   rq   z(test_generic_function.<locals>.test_funcrr   )ro   r   r    r   )r   intre   rR   rE   rD   r;   )rr   s    r*   test_generic_functionru      s        	#====)CH*=======9R==NIcN2..4444"444444 44444!%OOOOO,,,,8++++++rI   c                     t            G d d                      } t          j        t                    5   G d d|           }ddd           dS # 1 swxY w Y   dS )zTest that subclassing a @final-annotated class is not allowed.

    This checks both runtime results, and verifies that type checkers detect
    the error statically through the type-ignore comment.
    c                      e Zd ZdS )(test_final_decorator.<locals>.FinalClassNrD   r;   rE   rL   rI   r*   
FinalClassrx      s        rI   rz   c                      e Zd ZdS )&test_final_decorator.<locals>.SubClassNry   rL   rI   r*   SubClassr|      s        DrI   r}   N)r   r.   r/   rd   )rz   r}   s     r*   test_final_decoratorr~      s            U 
y	!	!  	 	 	 	 	z 	 	 	                 s   AAAc                      G d dt                     } t          j        t                    5   | dd           ddd           n# 1 swxY w Y   t	          |                     dd          |           sJ dS )zLThe NoPublicConstructor metaclass prevents calling the constructor directly.c                      e Zd Zd	dZdS )
:test_no_public_constructor_metaclass.<locals>.SpecialClassart   bfloatr    r!   c                &    |dk    sJ |dk    sJ dS )z*Check arguments can be passed to __init__.   333333	@NrL   )selfr   r   s      r*   rC   zCtest_no_public_constructor_metaclass.<locals>.SpecialClass.__init__   s     6666999999rI   N)r   rt   r   r   r    r!   )rD   r;   rE   rC   rL   rI   r*   SpecialClassr      s(        	 	 	 	 	 	rI   r   )	metaclassr   r   N)r   )r   r.   r/   rd   
isinstance_create)r   s    r*   $test_no_public_constructor_metaclassr      s        !4     
y	!	!  Q               l**1*55|DDDDDDDs   AAAc                    t          j        d          } d | _        d| j        _        d| j        _        t          | j        t          |                      | j        j        dk    sJ | j        j        dk    sJ t          j        d          }d |_        d|j        _        d|j        _        t          j                    |_        d|j        _        t          j                    |_	        d|j	        _
        d|j	        _        d	 |_        d|j        _
        d
x|j        _        |j        _        t          ddd d d          |_        |j        |j        _        t          dt          |                     |j        j        dk    sJ |j        j
        dk    sJ |j        j        dk    sJ |j        j        dk    sJ |j        j        d
k    sJ |j        j
        dk    sJ |j        j        d
k    sJ |j	        j        dk    sJ |j	        j
        dk    sJ t          |j	        d          rJ |j        j        j        dk    sJ |j        j        j
        dk    sJ |j        j        j        dk    sJ |                                  |                                 |                                 |                                                                 d S )Nnot_trioc                     d S r)   rL   rL   rI   r*   r^   z,test_fixup_module_metadata.<locals>.<lambda>   s     rI   	some_funcztrio._somemodule_implc                     d S r)   rL   rL   rI   r*   r^   z,test_fixup_module_metadata.<locals>.<lambda>   s    D rI   _something_elsenot_funclike	only_namec                     d S r)   rL   rL   rI   r*   r^   z,test_fixup_module_metadata.<locals>.<lambda>   s    4 rI   _private	SomeClassrL   c                    d S r)   rL   r   s    r*   r^   z,test_fixup_module_metadata.<locals>.<lambda>   s    T rI   c                    d S r)   rL   r   s    r*   r^   z,test_fixup_module_metadata.<locals>.<lambda>   s    4 rI   )rC   methodztrio.somemoduleonly_has_namerE   r   zSomeClass.method)types
ModuleTyper   rD   rE   r   varsSimpleNamespacer   r   r;   r   typer   	recursionhasattrr   )non_trio_modulemods     r*   test_fixup_module_metadatar      s   &z22O ,O)4O&-8O*/2D4I4IJJJ$-<<<<$1[@@@@ 
2
3
3C LCM.CM!2CM ,..C .C -//C#:C !,C  <CL5CL8BBCLCL5 
))''	
 	
 CM "mCM+T#YY777=![0000=#'88888=%4444$6666< J....<"&=====<$
2222%8888'+<<<<<s(.99999=(H4444=*.?????=,0BBBBBMMOOOLLNNNMMOOrI   c            	       K   t          d          } t          d          }t          d          }|| _        || _        t
          j                                        }t          j	        t           d          5 }t          t          d| g                     d d d            n# 1 swxY w Y   |j        j        |k    sJ |j        j        |k    sJ t          d| g          }t          d          }t          d          }||_        ||_        t          t          t           d	          d
          5 }t          t          d|g                     d d d            n# 1 swxY w Y   |j        j        |k    sJ |j        j        |k    sJ t          j	        t           d          5 }t          t          d||| g                     d d d            n# 1 swxY w Y   |j        j        |k    sJ |j        j        |k    sJ t          dt          d          t          d          g          }	t          j	        t           d          5 }t          |	           d d d            n# 1 swxY w Y   |j        j        |	u sJ |j        j        J t          dt          d          t          d          t#          d          g          }
t          j	        t"          d          5 }t          |
           d d d            n# 1 swxY w Y   |j        j        |
u sJ |j        j        J t          dt          d          t          d          t%          d          g          }t          j	        t$          d          5 }t          |           d d d            n# 1 swxY w Y   |j        j        |u sJ |j        j        J t          j	        t
          j        d          5 }t          t          d|t
          j                                        g                     d d d            n# 1 swxY w Y   |j        |u sJ |j        j        J |j        j        J d S )Nfoocausecontextr&    zinner egzinner eg causezinner eg contextz^foo$z
^inner eg$barzy^Attempted to unwrap exceptiongroup with multiple non-cancelled exceptions. This is often caused by a bug in the caller.$zthis exc doesn't get reraisedz^$z^Cancelled$)
ValueErrorSyntaxErrorrd   	__cause____context__r6   r7   r   r.   r/   r   r   rf   r
   r	   r   r   KeyboardInterrupt
SystemExit)excr   r   	cancelledrk   inner_eginner_causeinner_contexteginfoegeg_kisystemexit_kis               r*   &test_raise_single_exception_from_groupr     s/      U

C  E	""GCMCO&&((I	z	/	/	/ E7).cU*C*CDDDE E E E E E E E E E E E E E E="e++++=$//// j3%00H.//K011M$H(H	WZw777|	L	L	L JPV).hZ*H*HIIIJ J J J J J J J J J J J J J J<![0000<#}4444	z	/	/	/ 
7)rIy##>??	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ="e++++=$//// 
Z..
50A0AB	C	CB	 K
 
 
 . 
)"---	. . . . . . . . . . . . . . .
 ="b((((=$,,, 
uu=>>	
 E 
(	6	6	6 1')%0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1="e++++=$,,, '
uu677	
 M 
z	/	/	/ 97)-8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9="m3333=$,,, 
t~^	<	<	< 
)rIt~/E/E/G/G#HII	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 =I%%%%="***=$,,,,,s~   7B""B&)B&3EE"%E"(!GGGI''I+.I+%LLL?NN"N$<P,,P03P0r,   )1
__future__r   rg   r   typingr   r   collections.abcr   r   r   r.   r6   r:   r	   r
   r   r   _core._tests.tutilr   r   _utilr   r   r   r   r   r   r   r   r   r@   r   rh   exceptiongroupr   r   r   r4   rH   rN   markfilterwarningsrm   ru   r~   r   r   r   rL   rI   r*   <module>r      s   " " " " " " 



  ) ) ) ) ) ) ) ) EDDDDDDDDDD   - - - - - - - -             
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 - , , , , ,gAAAAAAAA /......GCLL. . . ..> > > >03 3 3 3 FGG< < < HG<~, , , ,   "E E E E A A A AHN- N- N- N- N- N-rI   