
    Mh                         S r SSKrSSKrSSKJrJr  SSKJr  \R                  " \
\\\\\\/S9S 5       r\R                  " \
\4\\4\\
4\\4\\4\\4\\4\\4/S S9S 5       rS	 r\R$                  R'                  S
5      S 5       r\R$                  R+                  S/ SQ5      S 5       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PerformanceWarning)paramsc                     U R                   $ )zl
Return unique warning.

Useful for testing behavior of tm.assert_produces_warning with various categories.
paramrequests    `/var/www/html/env/lib/python3.13/site-packages/pandas/tests/util/test_assert_produces_warning.pycategoryr      s    " ==    c                 ,    [        U 5      R                  $ N)type__name__)xs    r   <lambda>r   /   s    $q'""r   )r   idsc                     U R                   $ )z
Return pair or different warnings.

Useful for testing how several different warnings are handled
in tm.assert_produces_warning.
r   r	   s    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   zignore:f1:FutureWarningc                  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-   @   sp     ,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/z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})r2   z^Mes.*\d{2}-\d{3})r2   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_matchr6   L   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_warningr<   a   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"   r8   r9   )r   r&   r'   r(   r)   r*   r   r   r:   s      r   !test_fail_to_match_future_warningr@   p   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"   r8   r9   )ResourceWarningr&   r'   r(   r)   r*   r   r   r:   s      r   #test_fail_to_match_resource_warningrC      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_warningrH      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 OKr4   )r   rF   extra_categorys      r   test_ignore_extra_warningrL      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"   rJ   zUnexpected warning NOT OKrE   )r   rF   rK   r#   s       r   test_raise_on_extra_warningrN      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_matchrV      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)NrP   r"   rR   rS   rQ   )DeprecationWarningr)   r*   r   r   rU   s    r   0test_same_category_different_messages_last_matchrZ      sP    !H		#	#HN	C)840(;lH- 
D	C	CrW   c                      [         [        4n [        R                  " U SS9   [        R
                  " S[         5        [        R
                  " S[        5        S S S 5        g ! , (       d  f       g = f)NrP   r"   rQ   zMatch this too)r   rT   r)   r*   r   r   rU   s    r   test_match_multiple_warningsr\      sF    {+H		#	#HN	ClM2&4 
D	C	Cs   7A""
A0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"   rP   zDo not match itrQ   rE   )r   target_categoryother_categorys      r   &test_right_category_wrong_match_raisesr`      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   )selfra   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*   rf   ra   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   rj   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__rg   rk   rn   __static_attributes__r   r   r   rc   rc      s    r   rc   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)Nz3Did not see expected warning of class 'UserWarning'r"   r   zCaused unexpected warning)r&   r'   r(   r)   r*   rT   
ValueErrorr   r   r   
IndexErrorSystemErrorr+   s    r   test_raises_during_exceptionrx      s    
?C	~S	1''4 544 
2	1	1 
~S	1''4MM/=9 544 
2	1	1
 &C	~S	1''-MM/=9 .-- 
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*   ru   r   r   r   r   r   r   test_passes_during_exceptionr|      s    	{'	2''-g&& .-- 
3	2	2 
z	1''_MMM/=9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   rB   rT   r   rY   r   r   r   markfilterwarningsr-   parametrizer6   r<   r@   rC   rH   rL   rN   rV   rZ   r\   r`   rc   rx   r|   r   r   r   <module>r      s    
  

 	%	m$	'	/0	]+	)*	,-	*+	 	#(
 56 7  )! )
BBB>?G<.58 5$-8  9 $&r   