
    i'                        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$                  j'                  d	e
eeeeeeg      ej$                  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$                  j'                  dddg       G d d             Z#d Z$d  Z%y)!zH "
Test module for testing ``pandas._testing.assert_produces_warning``.
    N)DtypeWarningPerformanceWarningc                 ,    t        |       j                  S N)type__name__)xs    k/app/cer_product_mecsu/.venv/lib/python3.12/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                  l    t        j                  dt               t        j                  dt               y )Nf1f2)warningswarnFutureWarningRuntimeWarning r   r
   fr   (   s    MM$&MM$'r   c                  L   d} t        j                  t        |       5  t        j                  t
              5  t                d d d        d d d        t        j                  t
        d      5  t                d d d        y # 1 sw Y   @xY w# 1 sw Y   DxY w# 1 sw Y   y xY w)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)   -   s    
+C	~S	1 ''7 	C	 
	#	#NE	R 	 	 	  s.   BB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                     t        j                  | |      5  t        j                  ||        d d d        y # 1 sw Y   y xY w)Nr   r%   r&   r   r   )r*   messager   s      r
   %test_catch_warning_category_and_matchr3   8   s7    : 
	#	#HE	: )gx() ) )s	   8Ac                  (   t         } d}d}t        j                  t        |      5  t	        j
                  | |      5  t        j                  d|        t        j                  d|        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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   s    H&E	<  
~Y	7 B''> 	BMM0(;MM6A	BB B	B 	BB B"   B-A<+B<B	BBc                  (   t         } d}d}t        j                  t        |      5  t	        j
                  | |      5  t        j                  d|        t        j                  d|        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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   s    HE	;  
~Y	7 B''> 	BMM0(;MM6A	BB B	B 	BB Br:   c                  (   t         } d}d}t        j                  t        |      5  t	        j
                  | |      5  t        j                  d|        t        j                  d|        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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   s    HE	=  
~Y	7 B''> 	BMM0(;MM6A	BB B	B 	BB Br:   c                     | \  }}d}t        j                  t        |      5  t        j                  |      5  t        j                  d|       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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      sm    )@&3E	~U	3 >''(9: 	>MM+_=	>> >	> 	>> >s"   A-A!A-!A*	&A--A6c                     | \  }}t        j                  |d      5  t        j                  d|       t        j                  d|       d d d        y # 1 sw Y   y xY w)NFr    Expected warningzUnexpected warning OKr1   )r   rC   extra_categorys      r
   test_ignore_extra_warningrI      sR    (?%~		#	#$5u	U ?(*;<-~>? ? ?s   -AAc                    | \  }}d}t        j                  t        |      5  t        j                  |      5  t        j                  d|       t        j                  d|       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r   rG   zUnexpected warning NOT OKrB   )r   rC   rH   r   s       r
   test_raise_on_extra_warningrK      s    (?%~-E	~U	3 G''(9: 	GMM,.?@MM5~F	GG G	G 	GG Gs"   B-A7&B7B 	<BBc                      t         } t        j                  | d      5  t        j                  d|        t        j                  d|        t        j                  d|        d d d        y # 1 sw Y   y xY w)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      sX    H		#	#HN	C <lH-)840(;< < <   AA**A3c                      t         } t        j                  | d      5  t        j                  d|        t        j                  d|        t        j                  d|        d d d        y # 1 sw Y   y xY w)NrM   r   rO   rP   rN   )DeprecationWarningr%   r&   r   r   rR   s    r
   0test_same_category_different_messages_last_matchrW      sX    !H		#	#HN	C .)840(;lH-. . .rT   c                      t         t        f} t        j                  | d      5  t	        j
                  dt                t	        j
                  dt               d d d        y # 1 sw Y   y xY w)NrM   r   rN   zMatch this toor   rQ   r%   r&   r   r   rR   s    r
   test_match_multiple_warningsrZ      sN    {+H		#	#HN	C 5lM2&45 5 5s   5A""A+c                     t         t        f} d}t        j                  t        |      5  t        j                  | d      5  t        j                  dt                d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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_      sl    {+H
?C	~S	1 7''G 	7MM,6	77 7	7 	77 7s#   A:A.A:.A7	3A::Bc                  @   t         t        f} d}t        j                  t        |      5  t        j                  | d      5  t        j                  dt                t        j                  dt               d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nz>The emitted warning messages are \[UserWarning\('Not this'\)\]r   rM   rN   Not thisr]   r^   s     r
   *test_must_match_multiple_warnings_messagesrb      sz    {+H
KC	~S	1 3''G 	3MM,6MM*k2	33 3	3 	33 3s#   B5B7BB	BBc                      t         t        f} t        j                  | dd      5  t	        j
                  dt                d d d        y # 1 sw Y   y xY w)NrM   Fr   must_find_all_warningsrN   rY   rR   s    r
   .test_allow_partial_match_for_multiple_warningsrf      sF    {+H		#	#u
 3 	lM23 3 3s   A		Ac                      t         t        f} t        j                  | dd      5  t	        j
                  dt                t	        j
                  dt               d d d        y # 1 sw Y   y xY w)NrM   Frd   rN   ra   rY   rR   s    r
   7test_allow_partial_match_for_multiple_warnings_messagesrh      sT    {+H		#	#u
 / 	lM2j+.	/ / /s   5A##A,c                    | \  }}t        j                  t        d      5  t        j                  |d      5  t        j                  d|       t        j                  d|       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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      sw    &=#O^	~-L	M 8''~N 	8MM+_=MM,7	88 8	8 	88 8s"   B-A7&B7B 	<BBfalse_or_noneFc                       e Zd Zd Zd Zd Zy)TestFalseOrNoneExpectedWarningc                     d}t        j                  t        |      5  t        j                  |      5  t                d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r   )r"   r#   r$   r%   r&   r   )selfrm   r(   s      r
   test_raise_on_warningz4TestFalseOrNoneExpectedWarning.test_raise_on_warning   sW    /]]>5 	++M: 	 	 	 	s!   AAAA	AA%c                 Z    t        j                  |      5  	 d d d        y # 1 sw Y   y xY wr   )r%   r&   rq   rm   s     r
   test_no_raise_without_warningz<TestFalseOrNoneExpectedWarning.test_no_raise_without_warning   s(    ''6 		 	 	s   !*c                 p    t        j                  |d      5  t                d d d        y # 1 sw Y   y xY w)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 	C	 	 	s   ,5N)r   
__module____qualname__rr   ru   rw   r   r   r
   ro   ro      s    r   ro   c                     d} t        j                  t        |       5  t        j                  t
              5  t        # 1 sw Y   nxY w	 d d d        n# 1 sw Y   nxY wt        j                  t        |       5  t        j                  t
              5  t        j                  dt               t        # 1 sw Y   nxY w	 d d d        n# 1 sw Y   nxY wd} t        j                  t        |       5  t        j                  d       5  t        j                  dt               t        # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)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 		 	 	   
~S	1 ''4 	MM 		 	 	   &C	~S	1 ''- 	MM 		 	 	  sV   A?A	AA<C!B77C 	<CC6E!D--D6	2EEc                     t        j                  t        d      5  t        j                  d       5  t        d      # 1 sw Y   nxY w	 d d d        n# 1 sw Y   nxY wt        j                  t
        d      5  t        j                  t        d      5  t        j                  dt               t        d      # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)NErrorr   r   )	r"   r#   SyntaxErrorr%   r&   r{   r   r   r   r   r   r
   test_passes_during_exceptionr     s    	{'	2 '''- 	'g&&	' 	' 	'' ' ' 
z	1 &''_M 	&MM W%%		& 	& 	&& & &s8   A>A	AA;C&B==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      sv    
  	%	m$	'	/0	]+	)*	,-	*+	 	#(
   )!8)
BBB>?G<.5733/8 5$-8  9 ,
&r   