
    Pi'                        d Z ddlZddlZddlmZmZ ddlmZ  ej	        e
efeefee
feefeefeefeefeefgd           d             Zd Zd Zej                            d	e
eeeeeeg          ej                            d
g d          d                         Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"ej                            dddg           G d d                      Z#d Z$d  Z%dS )!zH "
Test module for testing ``pandas._testing.assert_produces_warning``.
    N)DtypeWarningPerformanceWarningc                 *    t          |           j        S N)type__name__)xs    /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/util/test_assert_produces_warning.py<lambda>r      s    $q''"     )paramsidsc                     | j         S )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                  n    t          j        dt                     t          j        dt                     d S )Nf1f2)warningswarnFutureWarningRuntimeWarning r   r
   fr   (   s,    M$&&&M$'''''r   c                  r   d} t          j        t          |           5  t          j        t
                    5  t                       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
          d          5  t                       d d d            d S # 1 swxY w Y   d S )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)   -   se   
+C	~S	1	1	1  '77 	 	CCC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	               
	#NE	R	R	R  	                 sF   A*AA*A	A*A	A**A.1A.B,,B03B0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                     t          j        | |          5  t          j        ||            d d d            d S # 1 swxY w Y   d S )Nr   r%   r&   r   r   )r*   messager   s      r
   %test_catch_warning_category_and_matchr3   8   s    : 
	#HE	:	:	: ) )gx((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   :>>c                  4   t           } d}d}t          j        t          |          5  t	          j        | |          5  t          j        d|            t          j        d|            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 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   sG   H&E	<  
~Y	7	7	7 B B'>>> 	B 	BM0(;;;M6AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	BB B B B B B B B B B B B B B B B B B4   B+A5)B5A9	9B<A9	=BBBc                  4   t           } d}d}t          j        t          |          5  t	          j        | |          5  t          j        d|            t          j        d|            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 )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   sG   HE	;  
~Y	7	7	7 B B'>>> 	B 	BM0(;;;M6AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	BB B B B B B B B B B B B B B B B B Br:   c                  4   t           } d}d}t          j        t          |          5  t	          j        | |          5  t          j        d|            t          j        d|            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\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   sG   HE	=  
~Y	7	7	7 B B'>>> 	B 	BM0(;;;M6AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	BB B B B B B B B B B B B B B B B B Br:   c                     | \  }}d}t          j        t          |          5  t          j        |          5  t          j        d|           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 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      s   )@&3E	~U	3	3	3 > >'(9:: 	> 	>M+_===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>> > > > > > > > > > > > > > > > > >s4   A2AA2A	A2!A	"A22A69A6c                     | \  }}t          j        |d          5  t          j        d|           t          j        d|           d d d            d S # 1 swxY w Y   d S )NFr    Expected warningzUnexpected warning OKr1   )r   rC   extra_categorys      r
   test_ignore_extra_warningrI      s    (?%~		#$5u	U	U	U ? ?(*;<<<-~>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?s   +AAAc                 (   | \  }}d}t          j        t          |          5  t          j        |          5  t          j        d|           t          j        d|           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 )Nr   r   rG   zUnexpected warning NOT OKrB   )r   rC   rH   r   s       r
   test_raise_on_extra_warningrK      s>   (?%~-E	~U	3	3	3 G G'(9:: 	G 	GM,.?@@@M5~FFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	GG G G G G G G G G G G G G G G G G Gs4   B+A/#B/A3	3B6A3	7BBBc                      t           } t          j        | d          5  t          j        d|            t          j        d|            t          j        d|            d d d            d S # 1 swxY w Y   d S )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      s    H		#HN	C	C	C < <lH---)84440(;;;< < < < < < < < < < < < < < < < < <   A A++A/2A/c                      t           } t          j        | d          5  t          j        d|            t          j        d|            t          j        d|            d d d            d S # 1 swxY w Y   d S )NrM   r   rO   rP   rN   )DeprecationWarningr%   r&   r   r   rR   s    r
   0test_same_category_different_messages_last_matchrW      s    !H		#HN	C	C	C . .)84440(;;;lH---. . . . . . . . . . . . . . . . . .rT   c                      t           t          f} t          j        | d          5  t	          j        dt                      t	          j        dt                     d d d            d S # 1 swxY w Y   d S )NrM   r   rN   zMatch this toor   rQ   r%   r&   r   r   rR   s    r
   test_match_multiple_warningsrZ      s    {+H		#HN	C	C	C 5 5lM222&4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   5A''A+.A+c                     t           t          f} d}t          j        t          |          5  t          j        | d          5  t          j        dt                      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 )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	1	1 7 7'GGG 	7 	7M,666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	77 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7s5   BA*B*A.	.B1A.	2BB	Bc                  R   t           t          f} d}t          j        t          |          5  t          j        | d          5  t          j        dt                      t          j        dt                     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>The emitted warning messages are \[UserWarning\('Not this'\)\]r   rM   rN   Not thisr]   r^   s     r
   *test_must_match_multiple_warnings_messagesrb      s   {+H
KC	~S	1	1	1 3 3'GGG 	3 	3M,666M*k222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s5   B5B8BB	BB	BB #B c                      t           t          f} t          j        | dd          5  t	          j        dt                      d d d            d S # 1 swxY w Y   d S )NrM   Fr   must_find_all_warningsrN   rY   rR   s    r
   .test_allow_partial_match_for_multiple_warningsrf      s    {+H		#u
 
 
 3 3 	lM2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s   AAAc                      t           t          f} t          j        | dd          5  t	          j        dt                      t	          j        dt                     d d d            d S # 1 swxY w Y   d S )NrM   Frd   rN   ra   rY   rR   s    r
   7test_allow_partial_match_for_multiple_warnings_messagesrh      s    {+H		#u
 
 
 / / 	lM222j+...	/ / / / / / / / / / / / / / / / / /s   5A((A,/A,c                 (   | \  }}t          j        t          d          5  t          j        |d          5  t          j        d|           t          j        d|           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 see warning.*matchingr   rM   zDo not match itrN   rB   )r   target_categoryother_categorys      r
   &test_right_category_wrong_match_raisesrl      s   &=#O^	~-L	M	M	M 8 8'~NNN 	8 	8M+_===M,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 8 8 8 8 8 8 8s4   B+A/#B/A3	3B6A3	7BBBfalse_or_noneFc                        e Zd Zd Zd Zd ZdS )TestFalseOrNoneExpectedWarningc                     d}t          j        t          |          5  t          j        |          5  t                       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 )Nr   r   )r"   r#   r$   r%   r&   r   )selfrm   r(   s      r
   test_raise_on_warningz4TestFalseOrNoneExpectedWarning.test_raise_on_warning   s    /]>555 	 	+M::                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s4   A&AA&A	A&A	A&&A*-A*c                 b    t          j        |          5  	 d d d            d S # 1 swxY w Y   d S r   )r%   r&   rq   rm   s     r
   test_no_raise_without_warningz<TestFalseOrNoneExpectedWarning.test_no_raise_without_warning   sz    '66 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   $((c                     t          j        |d          5  t                       d d d            d S # 1 swxY w Y   d S )NFr    )r%   r&   r   rt   s     r
   'test_no_raise_with_false_raise_on_extrazFTestFalseOrNoneExpectedWarning.test_no_raise_with_false_raise_on_extra   s    'uUUU 	 	CCC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   377N)r   
__module____qualname__rr   ru   rw   r   r   r
   ro   ro      sA                r   ro   c                     d} t          j        t          |           5  t          j        t
                    5  t          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          j        t          |           5  t          j        t
                    5  t          j        dt                     t          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   d} t          j        t          |           5  t          j        d           5  t          j        dt                     t          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )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	1	1  '44 	 		 	 	 	 	 	 	 	 	               
~S	1	1	1  '44 	 	M   		 	 	 	 	 	 	 	 	               &C	~S	1	1	1  '-- 	 	M   		 	 	 	 	 	 	 	 	                 s   AA  A	AA	AAA>C"B::B>	>CB>	CCC:E
"D11D5	5E
8D5	9E

EEc                     t          j        t          d          5  t          j        d           5  t          d          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   t          j        t
          d          5  t          j        t          d          5  t          j        dt                     t          d          # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )NErrorr   r   )	r"   r#   SyntaxErrorr%   r&   r{   r   r   r   r   r   r
   test_passes_during_exceptionr     s   	{'	2	2	2 ' ''-- 	' 	'g&&&	' 	' 	' 	' 	' 	' 	' 	' 	'' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 
z	1	1	1 & &'_MMM 	& 	&M   W%%%		& 	& 	& 	& 	& 	& 	& 	& 	&& & & & & & & & & & & & & & & & & &s^   AAA	AA		AA A?C*CC			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      s            
       	%	m$	'	/0	]+	)*	,-	*+	 	#"    ( ( (
         ) )!  8)
B B BB B BB B B> > >? ? ?G G G< < <. . .5 5 57 7 73 3 33 3 3/ / /8 8 8 5$-88       98   ,
& 
& 
& 
& 
&r   