
    I j'                        S r SSKrSSKrSSKJrJr  SSKJr  \R                  " \
\4\\4\\
4\\4\\4\\4\\4\\4/S S9S 5       rS rS r\R$                  R'                  S	\
\\\\\\/5      \R$                  R'                  S
/ SQ5      S 5       5       rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"\R$                  R'                  SSS/5       " S S5      5       r#S r$S  r%g)!zG"
Test module for testing ``pandas._testing.assert_produces_warning``.
    N)DtypeWarningPerformanceWarningc                 ,    [        U 5      R                  $ N)type__name__)xs    /root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/tests/util/test_assert_produces_warning.py<lambda>r      s    $q'""    )paramsidsc                     U R                   $ )z
Return pair or different warnings.

Useful for testing how several different warnings are handled
in tm.assert_produces_warning.
)param)requests    r
   pair_different_warningsr      s    ( ==r   c                  p    [         R                  " S[        5        [         R                  " S[        5        g )Nf1f2)warningswarnFutureWarningRuntimeWarning r   r
   fr   (   s    MM$&MM$'r   c                  d   Sn [         R                  " [        U S9   [        R                  " [
        5         [        5         S S S 5        S S S 5        [        R                  " [
        SS9   [        5         S S S 5        g ! , (       d  f       NC= f! , (       d  f       NL= f! , (       d  f       g = f)NCaused unexpected warning\(s\)matchFraise_on_extra_warnings)pytestraisesAssertionErrortmassert_produces_warningr   r   msgs    r
   *test_assert_produces_warning_honors_filterr)   -   sn    
+C	~S	1''7C 8 
2 
	#	#NE	R	 
S	R 87 
2	1 
S	Rs.   BA?B+B!?
B		B
B!
B/categoryzmessage, match)) N)r+   r+   )Warning messagez.*)r,   War)r,   z
[Ww]arning)r,   age)r,   zage$)Message 12-234 with numbersz\d{2}-\d{3})r/   z^Mes.*\d{2}-\d{3})r/   z\d{2}-\d{3}\s\S+)zMessage, which we do not matchNc                     [         R                  " XS9   [        R                  " X5        S S S 5        g ! , (       d  f       g = f)Nr   r%   r&   r   r   )r*   messager   s      r
   %test_catch_warning_category_and_matchr3   8   s*    : 
	#	#H	:g( 
;	:	:s	   5
Ac                  6   [         n SnSn[        R                  " [        US9   [        R
                  " XS9   [        R                  " SU 5        [        R                  " SU 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NzDid not see this warningzDid not see warning 'RuntimeWarning' matching 'Did not see this warning'. The emitted warning messages are \[RuntimeWarning\('This is not a match.'\), RuntimeWarning\('Another unmatched warning.'\)\]r   This is not a match.Another unmatched warning.)r   r"   r#   r$   r%   r&   r   r   r*   r   	unmatcheds      r
   "test_fail_to_match_runtime_warningr9   Y   so    H&E	<  
~Y	7''>MM0(;MM6A ? 
8	7>> 
8	7"   B
/A9(B
9
B	B


Bc                  6   [         n SnSn[        R                  " [        US9   [        R
                  " XS9   [        R                  " SU 5        [        R                  " SU 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NWarningzDid not see warning 'FutureWarning' matching 'Warning'. The emitted warning messages are \[FutureWarning\('This is not a match.'\), FutureWarning\('Another unmatched warning.'\)\]r   r5   r6   )r   r"   r#   r$   r%   r&   r   r   r7   s      r
   !test_fail_to_match_future_warningr=   h   so    HE	;  
~Y	7''>MM0(;MM6A ? 
8	7>> 
8	7r:   c                  6   [         n SnSn[        R                  " [        US9   [        R
                  " XS9   [        R                  " SU 5        [        R                  " SU 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nz\d+zDid not see warning 'ResourceWarning' matching '\\d\+'. The emitted warning messages are \[ResourceWarning\('This is not a match.'\), ResourceWarning\('Another unmatched warning.'\)\]r   r5   r6   )ResourceWarningr"   r#   r$   r%   r&   r   r   r7   s      r
   #test_fail_to_match_resource_warningr@   w   so    HE	=  
~Y	7''>MM0(;MM6A ? 
8	7>> 
8	7r:   c                    U u  pSn[         R                  " [        US9   [        R                  " U5         [
        R                  " SU5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nz%Did not see expected warning of classr   zwarning messager"   r#   r$   r%   r&   r   r   )r   expected_categoryactual_categoryr   s       r
   !test_fail_to_catch_actual_warningrE      sY    )@&3E	~U	3''(9:MM+_= ; 
4	3:: 
4	3s"   A1A A1 
A.	*A11
A?c                     U u  p[         R                  " USS9   [        R                  " SU5        [        R                  " SU5        S S S 5        g ! , (       d  f       g = f)NFr    Expected warningzUnexpected warning OKr1   )r   rC   extra_categorys      r
   test_ignore_extra_warningrI      sH    (?%		#	#$5u	U(*;<-~> 
V	U	Us   /A
A c                 2   U u  pSn[         R                  " [        US9   [        R                  " U5         [
        R                  " SU5        [
        R                  " SU5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr   r   rG   zUnexpected warning NOT OKrB   )r   rC   rH   r   s       r
   test_raise_on_extra_warningrK      si    (?%-E	~U	3''(9:MM,.?@MM5~F ; 
4	3:: 
4	3s"   B/A7&B7
B	B
Bc                      [         n [        R                  " U SS9   [        R                  " SU 5        [        R                  " SU 5        [        R                  " SU 5        S S S 5        g ! , (       d  f       g = f)N^Match thisr   
Match thisDo not match thatDo not match that either)UserWarningr%   r&   r   r   r*   s    r
   1test_same_category_different_messages_first_matchrS      sP    H		#	#HN	ClH-)840(; 
D	C	C   AA++
A9c                      [         n [        R                  " U SS9   [        R                  " SU 5        [        R                  " SU 5        [        R                  " SU 5        S S S 5        g ! , (       d  f       g = f)NrM   r   rO   rP   rN   )DeprecationWarningr%   r&   r   r   rR   s    r
   0test_same_category_different_messages_last_matchrW      sP    !H		#	#HN	C)840(;lH- 
D	C	CrT   c                      [         [        4n [        R                  " U SS9   [        R
                  " S[         5        [        R
                  " S[        5        S S S 5        g ! , (       d  f       g = f)NrM   r   rN   zMatch this toor   rQ   r%   r&   r   r   rR   s    r
   test_match_multiple_warningsrZ      sF    {+H		#	#HN	ClM2&4 
D	C	Cs   7A""
A0c                     [         [        4n Sn[        R                  " [        US9   [
        R                  " U SS9   [        R                  " S[         5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)N3Did not see expected warning of class 'UserWarning'r   rM   rN   	r   rQ   r"   r#   r$   r%   r&   r   r   r*   r(   s     r
   !test_must_match_multiple_warningsr_      s[    {+H
?C	~S	1''GMM,6 H 
2	1GG 
2	1s"   A<A+A<+
A9	5A<<
B
c                  P   [         [        4n Sn[        R                  " [        US9   [
        R                  " U SS9   [        R                  " S[         5        [        R                  " S[        5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nz>The emitted warning messages are \[UserWarning\('Not this'\)\]r   rM   rN   Not thisr]   r^   s     r
   *test_must_match_multiple_warnings_messagesrb      si    {+H
KC	~S	1''GMM,6MM*k2 H 
2	1GG 
2	1s"   B7B5B
B	B
B%c                      [         [        4n [        R                  " U SSS9   [        R
                  " S[         5        S S S 5        g ! , (       d  f       g = f)NrM   Fr   must_find_all_warningsrN   rY   rR   s    r
   .test_allow_partial_match_for_multiple_warningsrf      sA    {+H		#	#u
 	lM2
 
 
s   A
Ac                      [         [        4n [        R                  " U SSS9   [        R
                  " S[         5        [        R
                  " S[        5        S S S 5        g ! , (       d  f       g = f)NrM   Frd   rN   ra   rY   rR   s    r
   7test_allow_partial_match_for_multiple_warnings_messagesrh      sO    {+H		#	#u
 	lM2j+.	
 
 
s   7A##
A1c                 ,   U u  p[         R                  " [        SS9   [        R                  " USS9   [
        R                  " SU5        [
        R                  " SU5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NzDid not see warning.*matchingr   rM   zDo not match itrN   rB   )r   target_categoryother_categorys      r
   &test_right_category_wrong_match_raisesrl      sf    &=#O	~-L	M''~NMM+_=MM,7 O 
N	MNN 
N	Ms"   B/A4#B4
B	>B
Bfalse_or_noneFc                   &    \ rS rSrS rS rS rSrg)TestFalseOrNoneExpectedWarning   c                     Sn[         R                  " [        US9   [        R                  " U5         [        5         S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr   r   )r"   r#   r$   r%   r&   r   )selfrm   r(   s      r
   test_raise_on_warning4TestFalseOrNoneExpectedWarning.test_raise_on_warning   sE    /]]>5++M: ; 65:: 65s!   A AA 
A	A  
A.c                 f    [         R                  " U5          S S S 5        g ! , (       d  f       g = fr   )r%   r&   rr   rm   s     r
   test_no_raise_without_warning<TestFalseOrNoneExpectedWarning.test_no_raise_without_warning   s    ''6 766s   "
0c                 v    [         R                  " USS9   [        5         S S S 5        g ! , (       d  f       g = f)NFr    )r%   r&   r   rv   s     r
   'test_no_raise_with_false_raise_on_extraFTestFalseOrNoneExpectedWarning.test_no_raise_with_false_raise_on_extra   s$    ''uUC VUUs   *
8r   N)r   
__module____qualname____firstlineno__rs   rw   rz   __static_attributes__r   r   r
   ro   ro      s    r   ro   c                     Sn [         R                  " [        U S9   [        R                  " [
        5         [        e! , (       d  f       O= f S S S 5        O! , (       d  f       O= f[         R                  " [        U S9   [        R                  " [
        5         [        R                  " S[        5        [        e! , (       d  f       O= f S S S 5        O! , (       d  f       O= fSn [         R                  " [        U S9   [        R                  " S 5         [        R                  " S[        5        [        e! , (       d  f       O= f S S S 5        g ! , (       d  f       g = f)Nr\   r   r   zCaused unexpected warning)r"   r#   r$   r%   r&   rQ   
ValueErrorr   r   r   
IndexErrorSystemErrorr'   s    r
   test_raises_during_exceptionr      s    
?C	~S	1''4 544 
2	1	1 
~S	1''4MM 	 544 
2	1	1 &C	~S	1''-MM 	 .-- 
2	1	1sV   A>
A	A
A'C"C  
C	
C
C)E"E  
E	
E
E)c                     [         R                  " [        SS9   [        R                  " S 5         [        S5      e! , (       d  f       O= f S S S 5        O! , (       d  f       O= f[         R                  " [
        SS9   [        R                  " [        SS9   [        R                  " S[        5        [        S5      e! , (       d  f       O= f S S S 5        g ! , (       d  f       g = f)NErrorr   r   )	r"   r#   SyntaxErrorr%   r&   r   r   r   r   r   r   r
   test_passes_during_exceptionr     s    	{'	2''-g&& .-- 
3	2	2 
z	1''_MMM W%%	 NMM 
2	1	1s8   A=
A	A
A&C'C
C	C
C,)&__doc__r   r"   pandas.errorsr   r   pandas._testing_testingr%   fixturer   rQ   r   rV   r?   r   r   r)   markparametrizer3   r9   r=   r@   rE   rI   rK   rS   rW   rZ   r_   rb   rf   rh   rl   ro   r   r   r   r   r
   <module>r      st    
  	%	m$	'	/0	]+	)*	,-	*+	 	#(
   )!8)
BBB>?G<.5733/8 5$-8  9 ,
&r   