
    Owg                         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eeeeeg      d        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ej$                  j'                  d
      d        Z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 ej$                  j+                  dddg       G d d             Z!d Z"d Z#y)zG"
Test module for testing ``pandas._testing.assert_produces_warning``.
    N)DtypeWarningPerformanceWarning)paramsc                     | j                   S )zx
    Return unique warning.

    Useful for testing behavior of tm.assert_produces_warning with various categories.
    paramrequests    e/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/util/test_assert_produces_warning.pycategoryr      s    " ==    c                 ,    t        |       j                  S N)type__name__)xs    r   <lambda>r   /   s    $q'"" r   )r   idsc                     | j                   S )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                  l    t        j                  dt               t        j                  dt               y )Nf1f2)warningswarnFutureWarningRuntimeWarning r   r   fr   ;   s    MM$&MM$'r   zignore:f1:FutureWarningc                  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#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                     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_matchr6   L   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_warningr<   a   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"   r8   r9   )r   r&   r'   r(   r)   r*   r   r   r:   s      r   !test_fail_to_match_future_warningr@   p   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"   r8   r9   )ResourceWarningr&   r'   r(   r)   r*   r   r   r:   s      r   #test_fail_to_match_resource_warningrC      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_warningrH      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 OKr4   )r   rF   extra_categorys      r   test_ignore_extra_warningrL      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"   rJ   zUnexpected warning NOT OKrE   )r   rF   rK   r#   s       r   test_raise_on_extra_warningrN      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_matchrV      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)NrP   r"   rR   rS   rQ   )DeprecationWarningr)   r*   r   r   rU   s    r   0test_same_category_different_messages_last_matchrZ      sX    !H		#	#HN	C .)840(;lH-. . .rW   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)NrP   r"   rQ   zMatch this too)r   rT   r)   r*   r   r   rU   s    r   test_match_multiple_warningsr\      sN    {+H		#	#HN	C 5lM2&45 5 5s   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"   rP   zDo not match itrQ   rE   )r   target_categoryother_categorys      r   &test_right_category_wrong_match_raisesr`      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   )selfra   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*   re   ra   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   rh   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__rf   ri   rk   r   r   r   rc   rc      s    r   rc   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)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_exceptionrr      s   
?C	~S	1 ''4 		 	 	   
~S	1 ''4 	MM/=9	 	 	  
 &C	~S	1 ''- 	MM/=9	 	 	  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*   ro   r   r   r   r   r   r   test_passes_during_exceptionrv      s    	{'	2 '''- 	'g&&	' 	' 	'' ' ' 
z	1 &''_M 	&MM/=9W%%	& 	& 	&& & &s8   A>A	AA;C&B==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   rr   rv   r   r   r   <module>r      s    
  

 	%	m$	'	/0	]+	)*	,-	*+	 	#(
 56 7  )! )
BBB>?G<.58 5$-8  9 $&r   