
     f6                        d dl mZ d dlZd dlZd dlmZ d dlmZ d dlZd dl	Z	d dl
mZmZ ej        dk     rd dlmZ ddZddZddZddZddZddZddZddZddZddZddZddZddZddZddZdS )     )annotationsN)TracebackType)Any)MatcherRaisesGroup)      )ExceptionGroupsstrreturnc                6    dt          j        |           z   dz   S )N^$)reescape)r   s    g/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/trio/_tests/test_testing_raisesgroup.pywrap_escaper      s    1##    Nonec                 	   t          j        t          t          dt	                      d                    5  t          t	                                 d d d            n# 1 swxY w Y   t          t                    5  t          dt                      f          # 1 swxY w Y   t          t                    5  t          t                    5  t          dt                      f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          t          t                    5  t          dt                      t                      f          # 1 swxY w Y   t          t          t                    5  t          dt                      t                      f          # 1 swxY w Y   t          t          t                              5  t          dt          dt                      f          f          # 1 swxY w Y   t          t          t          t                    t          t                              5  t          dt                      t          dt                      f          t          dt                      f          f          # 1 swxY w Y   t          j        t                    5  t          t                    5  t          dt                      t                      f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          j        t                    5  t          t                    5  t          dt                      t                      f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          j        t                    5  t          t          t                    5  t          dt                      f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          j        t                    5  t          t          t                    5  t          dt                      f          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )NzInvalid argument "z2" must be exception type, Matcher, or RaisesGroup.matchfoobar )	pytestraises
ValueErrorr   	TypeErrorr   r
   SyntaxErrorRuntimeError r   r   test_raises_groupr$      s   	bbbb
 

 
 
 ! ! 	IKK   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 
Z	 	  5 5UZ\\O4445 5 5 5 5 5 5 5 
[	!	! : :$$ 	: 	: (8999	: 	: 	: 	: 	: 	: 	: 	: 	:: : : : : : : : : : : : : : :
 
Z	-	- C CUZ\\;==$ABBBC C C C C C C C 
[*	-	- C CUZ\\;==$ABBBC C C C C C C C 
[,,	-	- O OU^EJLL?%K%K$MNNNO O O O O O O O 
JL!!
 
 
 

 uz||o66rLNN#455
 
 	

 
 
 
 
 
 
 
 
~	&	& C C$$ 	C 	C jllJLL%ABBB	C 	C 	C 	C 	C 	C 	C 	C 	CC C C C C C C C C C C C C C C 
~	&	& E E$$ 	E 	E lnnjll%CDDD	E 	E 	E 	E 	E 	E 	E 	E 	EE E E E E E E E E E E E E E E
 
~	&	& 6 6Z00 	6 	6 jll_555	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 
~	&	& 6 6[11 	6 	6 jll_555	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s\  A!!A%(A% BB"%B"=DC00C4	4D7C4	8DDD-+EEE=+F((F,/F,-HHHAJJ #J  L+L  L	LL	LLL<N+M<<N 	 NN 	NNN8P	O11O5	5P	8O5	9P		PP-Q?Q&&Q*	*Q?-Q*	.Q??RRc                 Z   t          t          d          5  t          dt          dt                      f          f          # 1 swxY w Y   t          t          t          d          5  t          dt          dt                      t                      f          f          # 1 swxY w Y   t          t          t          d          5  t          dt          dt                      g          t                      g          # 1 swxY w Y   t          t          t          d                    5  t          dt          dt                      f          f          # 1 swxY w Y   t          t          t          d                    5  t          dt          dt          dt                      f          f          f          # 1 swxY w Y   t	          j        t                    5  t          t          t          d                    5  t          dt                      f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t	          j        t          d          5  t          t          t                    d           d d d            d S # 1 swxY w Y   d S )NT)flatten_subgroupsr   z@^You cannot specify a nested structure inside a RaisesGroup withr   )r   r   r
   r    r   r   r#   r   r   test_flatten_subgroupsr'   R   s   	Z4	8	8	8 I IR.jll_"E"E!GHHHI I I I I I I I 
Zd	C	C	C U UR.jllIKK5P"Q"Q!STTTU U U U U U U U	Zd	C	C	C T TR.jll^"D"Dikk!RSSST T T T T T T T 
[tDDD	E	E I IR.jll_"E"E!GHHHI I I I I I I I	[tDDD	E	E 
 
^B%H%H$JKKM
 
 	

 
 
 
 
 
 
 
 
~	&	& 6 6Z4HHHII 	6 	6 jll_555	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6
 
P
 
 
 E E 	K
++tDDDD	E E E E E E E E E E E E E E E E E Es   -AAA+:B%%B),B):DD
D
4-E!!E%(E%<GGG/$I	H11H5	5I	8H5	9I		II/$J  J$'J$c            
     r   t          t          d          5  t          # 1 swxY w Y   t          j        t          d          5  t          t          t          d           d d d            n# 1 swxY w Y   t          t          d           d          5  t          # 1 swxY w Y   t          j        t          d          5  t          t          t                    d           d d d            n# 1 swxY w Y   t          t          t          d                    5  t          dt          dt                      g          g          # 1 swxY w Y   t          t          t          d                    5  t          dt                      g          # 1 swxY w Y   t          j        t          d	          5  t          t                    5  t          d
          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          j        t                    5  t          t          d          5  t          dt          dt                      g          g          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          t          dd          5  t          dt          dt                      g          g          # 1 swxY w Y   t          j        t                    5  t          t          d          5  t          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )NTallow_unwrappedz,^You cannot specify multiple exceptions withr   c                :    t          | t          t          f          S N)
isinstancer!   r   es    r   <lambda>z1test_catch_unwrapped_exceptions.<locals>.<lambda>}   s    
1{J.G H H r   checkzhas no effect when expectingr   z^value error text$zvalue error text)r*   r&   )r   r   r   r   r!   r   r
   r    r#   r   r   test_catch_unwrapped_exceptionsr3   o   s    
Z	6	6	6          
H
 
 
 C C 	KTBBBBC C C C C C C C C C C C C C C 
HHIII
 
 
   	        
z)G	H	H	H C CK
++TBBBBC C C C C C C C C C C C C C C
 
[TBBB	C	C G GR.jll^"D"D!EFFFG G G G G G G G	[TBBB	C	C 1 1R*,,0001 1 1 1 1 1 1 1 
z)=	>	>	> 1 1$$ 	1 	1/000	1 	1 	1 	1 	1 	1 	1 	1 	11 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 
~	&	& K KT::: 	K 	K nR*,,&H&H%IJJJ	K 	K 	K 	K 	K 	K 	K 	K 	KK K K K K K K K K K K K K K K
 
Z	N	N	N G GR.jll^"D"D!EFFFG G G G G G G G 
y	!	!  T::: 	 	O	 	 	 	 	 	 	 	 	                 s  ##A..A25A2B!!B%(B%$C77C;>C;%-EEE FF"%F"HG))G-	-H0G-	1HHH%J<-I))I-	-J0I-	1JJJ#-KKK4L,LL	L,L	L,,L03L0c                 >   t          t          d          5  t          dt                      f          # 1 swxY w Y   t          t          d          5  t          dt                      f          # 1 swxY w Y   t          t          d          5  t          dt                      f          } |                     d           | # 1 swxY w Y   t          t          d          5  t          dt                      f          } |                     d           | # 1 swxY w Y   t	          j        t                    5  t          t          d          5  t          dt                      f          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nr   r   ^bar$zmy notez^bar
my note$r   )r   r   r
   add_noter   r   r.   s    r   
test_matchr7      sw   	Zu	-	-	- 5 5UZ\\O4445 5 5 5 5 5 5 5 
Zw	/	/	/ 5 5UZ\\O4445 5 5 5 5 5 5 5 
Zy	1	1	1  5:<</22	

9        
Z'7	8	8	8  5:<</22	

9       
 
~	&	& 9 95111 	9 	9 888	9 	9 	9 	9 	9 	9 	9 	9 	99 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9sr   599A44A8;A85C

CC+5D  D$'D$FE99E=	=F E=	FFFc                 z    t          dt                      f           t          t           fd          5   # 1 swxY w Y   t          j        t                     5  t          t           fd          5  t          dt                      f          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nr   c                    | u S r,   r#   xexcs    r   r0   ztest_check.<locals>.<lambda>   s    c r   r1   c                    | u S r,   r#   r:   s    r   r0   ztest_check.<locals>.<lambda>   s    Q#X r   )r
   r   r   r   r   )r<   s   @r   
test_checkr>      sJ   
jll_
-
-C	Z'9'9'9'9	:	:	:  	       	~	&	& 6 6+=+=+=+=>>> 	6 	6 jll_555	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s=   ;??B09BB	B0B	B00B47B4c                 v   dd} d}t          j        t          t          j        |                    5  t          t          dd	
           d d d            n# 1 swxY w Y   t          j        t          t          j        |                    5  t          t          d|            d d d            n# 1 swxY w Y   t          t          t          d          d          }|5  t          d	          # 1 swxY w Y   |5  t          dt          d	          g          # 1 swxY w Y   t          t          d          5 }t          dt          d	          g          # 1 swxY w Y   t          |j	        t                    r0t          t          d          
                    |j	                  sJ d S d S )Nr/   objectr   boolc                    dS )NTr#   r.   s    r   my_checkz,test_unwrapped_match_check.<locals>.my_check   s    tr   av  `allow_unwrapped=True` bypasses the `match` and `check` parameters if the exception is unwrapped. If you intended to match/check the exception you should use a `Matcher` object. If you want to match/check the exceptiongroup when the exception *is* wrapped you need to do e.g. `if isinstance(exc.value, ExceptionGroup): assert RaisesGroup(...).matches(exc.value)` afterwards.r   Tr   )r*   r   )r*   r2   z^foo$r)   r   r   )r/   r@   r   rA   )r   r   r   r   r   r   r   r
   r-   valuematches)rC   msgrgr<   s       r   test_unwrapped_match_checkrH      s      	C  
z3	8	8	8 C CJEBBBBC C C C C C C C C C C C C C C	z3	8	8	8 F FJHEEEEF F F F F F F F F F F F F F F 
WZw777	N	N	NB	                   	 6 6R*U"3"3!45556 6 6 6 6 6 6 6 
Z	6	6	6 9#UZ%6%6$78889 9 9 9 9 9 9 9#)^,, G:U333;;CIFFFFFG GFFsY   AAAB44B8;B8&C66C:=C:D""D&)D&E""E&)E&c                    t          t                    } |                     d           rJ |                     t                                rJ |                     t          dt                      f                    sJ d S )Nr   )r   r   rE   r
   )rG   s    r   test_RaisesGroup_matchesrJ      sq    	Z	 	 Bzz$zz*,,'''''::nR*,,99:::::::r   c            	        dd}  | dt          t                                | d	t          t          t                                | d
t          t          t                                          | dt          t          t          d                                | dt          t          d                                | dt          t                                | dt          t          t                                          | dt          t          t                                          | dt          t          t                    t          t                                         d S )Nmessager   bodyRaisesGroup[Any]r   r   c                    t          j        t          dt          j        |            d          5  |5  	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nz'^DID NOT RAISE any exception, expected r   r   )r   r   AssertionErrorr   r   )rL   rM   s     r   check_messagez#test_message.<locals>.check_message   s    ]QBIg<N<NQQQ
 
 
 	 	                 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s3   AAAA	A
A	AA"AzExceptionGroup(ValueError)z&ExceptionGroup(ValueError, ValueError)z*ExceptionGroup(ExceptionGroup(ValueError))z3ExceptionGroup(Matcher(ValueError, match='my_str'))my_strz'ExceptionGroup(Matcher(match='my_str'))r   z%BaseExceptionGroup(KeyboardInterrupt)z.BaseExceptionGroup(Matcher(KeyboardInterrupt))z9BaseExceptionGroup(BaseExceptionGroup(KeyboardInterrupt))zUBaseExceptionGroup(BaseExceptionGroup(KeyboardInterrupt), ExceptionGroup(ValueError)))rL   r   rM   rN   r   r   )r   r   r   KeyboardInterrupt)rQ   s    r   test_messagerT      s       M.J0G0GHHHM0+j*2U2U   M4K
++,,   M=GJ1122   M1G(+++,,   M/=N1O1O   M8G-..//  
 MCK 12233  
 M_K 122K
4K4KLL    r   c            	        t          j        t          d          5  t                       d d d            n# 1 swxY w Y   t          j        t          dt	          j        t          t                               d          5  t          t                     d d d            n# 1 swxY w Y   t          t          t                              5  t          dt                      f          # 1 swxY w Y   t          j        t                    5  t          t          t                              5  t          dt                      f          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nz6^You must specify at least one parameter to match on.$r   z^exception_type z% must be a subclass of BaseException$r   )r   r   r   r   r   r   reprr@   r   r
   r    r#   r   r   test_matcherrW     sR   	R
 
 
   				               
_4<<!8!8___
 
 
   		               
WZ((	)	) 2 2R*,,1112 2 2 2 2 2 2 2	~	&	& 6 6++,, 	6 	6 jll_555	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s`   7;;B&&B*-B*C00C47C4"E-6EE	E-E	E--E14E1c                    t          t          t          d                    5  t          dt          d          f          # 1 swxY w Y   t	          j        t                    5  t          t          t          d                    5  t          dt          d          f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          t          d                    5  t          dt          d          f          # 1 swxY w Y   t	          j        t                    5  t          t          d                    5  t          dt          d          f          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          t          t          d                    5  t          dt          d          g          # 1 swxY w Y   t	          j        t                    5  t          t          t          d                    5  t          dt          d          g          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r5   barr)r   r   r   r
   r   r   r#   r   r   test_matcher_matchrZ   1  s   	WZ//	0	0 7 7R*U"3"3!56667 7 7 7 7 7 7 7	~	&	& ; ;U3344 	; 	; j&7&7%9:::	; 	; 	; 	; 	; 	; 	; 	; 	;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
 
W5)))	*	* 7 7R*U"3"3!56667 7 7 7 7 7 7 7	~	&	& ; ;u---.. 	; 	; j&7&7%9:::	; 	; 	; 	; 	; 	; 	; 	; 	;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
 
WZw777	8	8 6 6R*U"3"3!45556 6 6 6 6 6 6 6	~	&	& ; ;7;;;<< 	; 	; j&8&8%9:::	; 	; 	; 	; 	; 	; 	; 	; 	;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s   AA	A&#C 	B((B,	,C /B,	0C  CC(DDD+F 	E((E,	,F /E,	0F  FF.GGG1$IH44H8	8I;H8	<IIIc            	     D   dd} t          t          |                     5  t          dt          dd          f          # 1 swxY w Y   dd
}t          t          t          |                    5  t          dt          dd          f          # 1 swxY w Y   t	          j        t                    5  t          t          t          |                    5  t          dt          dd          f          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nr/   BaseExceptionr   rA   c                B    t          | t                    o
| j        dk    S N   )r-   OSErrorerrnor.   s    r   check_oserror_and_errno_is_5z8test_Matcher_check.<locals>.check_oserror_and_errno_is_5H  s    !W%%6!'Q,6r   r1   r   r_   r`   c                    | j         dk    S r^   )ra   r.   s    r   check_errno_is_5z,test_Matcher_check.<locals>.check_errno_is_5O  s    w!|r      )r/   r\   r   rA   )r/   r`   r   rA   )r   r   r
   r`   r   r   )rb   rd   s     r   test_Matcher_checkrf   G  s   7 7 7 7 
W#?@@@	A	A 4 4R'!R..!23334 4 4 4 4 4 4 4    
WW,<===	>	> 4 4R'!R..!23334 4 4 4 4 4 4 4 
~	&	& 8 80@AAABB 	8 	8 gann%6777	8 	8 	8 	8 	8 	8 	8 	8 	88 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8sS    AA	A4 BBB8$D C<<D 	 DD 	DDDc                    t          t          t                              dk    sJ t          t          d                    dk    sJ t          j        dd          } t          t          |                     dk    sJ t          j        dt          j                  }t          t          |                    d|d	k    sJ t          t          t          d
t                              dt          d	k    sJ d S )NzMatcher(ValueError)z[a-z]r   zMatcher(match='[a-z]')noflagr   zMatcher(match='noflag')zMatcher(match=)r   )r   r2   z&Matcher(ValueError, match='re', check=)r   r   r   r   compile
IGNORECASErA   )pattern_no_flagspattern_flagss     r   test_matcher_tostringrn   Z  s
   wz""##'<<<<<wW%%%&&*BBBBBz(A..w-...//3LLLLLJx77Mw]+++,,0S0S0S0SSSSSGJd$77788=D===	> 	> 	> 	> 	> 	>r   monkeypatchpytest.MonkeyPatchc                   |                      t          j        j        dt          j        j        j                   t          j                            t                    5 }t          dt          d          f          # 1 swxY w Y   |j        t          u sJ |j	        j
        d         j        dk    sJ t          |j        t                    sJ d S )NExceptionInfor   hellor   )rs   )setattrtriotesting_raises_group_ExceptionInfor   r   r
   typerD   
exceptionsargsr-   tbr   )ro   excinfos     r   test__ExceptionInfor~   g  s    ""1  
 
	!	!*	-	- 9R*W"5"5!78889 9 9 9 9 9 9 9<>))))=#A&+z9999gj-0000000s   A>>BBc                    t          j                    5  t          t          d           ddd           n# 1 swxY w Y   t          j                    5  t          t          d           ddd           dS # 1 swxY w Y   dS )z3`strict` has been replaced with `flatten_subgroups`F)strictNT)r   deprecated_callr   r   r#   r   r   test_deprecated_strictr   t  s    
		!	! . .Ju----. . . . . . . . . . . . . . .			!	! - -Jt,,,,- - - - - - - - - - - - - - - - - -s   7;;A99A= A=)r   r   r   r   )r   r   )ro   rp   r   r   )
__future__r   r   systypesr   typingr   r   ru   trio.testingr   r   version_infoexceptiongroupr
   r   r$   r'   r3   r7   r>   rH   rJ   rT   rW   rZ   rf   rn   r~   r   r#   r   r   <module>r      s   " " " " " " 				 



               - - - - - - - -g------$ $ $ $:6 :6 :6 :6zE E E E:/ / / /d9 9 9 966 6 6 6G G G G>; ; ; ;1 1 1 1h6 6 6 6$; ; ; ;,8 8 8 8&
 
 
 

1 
1 
1 
1- - - - - -r   