o
    ôT·jÜ   ã                
   @   sV  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�d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„ d	�d
d„ ƒZdd„ Zej d¡dd„ ƒZej dg d¢¡dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Z ej d)d*dg¡G d+d,„ d,ƒƒZ!d-d.„ Z"d/d0„ Z#dS )1zG"
Test module for testing ``pandas._testing.assert_produces_warning``.
é    N)ÚDtypeWarningÚPerformanceWarning)Úparamsc                 C   ó   | j S )zx
    Return unique warning.

    Useful for testing behavior of tm.assert_produces_warning with various categories.
    ©Úparam©Úrequest© r
   úq/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/pandas/tests/util/test_assert_produces_warning.pyÚcategory   s   r   c                 C   s
   t | ƒjS ©N)ÚtypeÚ__name__)Úxr
   r
   r   Ú<lambda>/   s   
 r   )r   Úidsc                 C   r   )z’
    Return pair or different warnings.

    Useful for testing how several different warnings are handled
    in tm.assert_produces_warning.
    r   r   r
   r
   r   Úpair_different_warnings$   s   r   c                   C   s   t  dt¡ t  dt¡ d S )NÚf1Úf2)ÚwarningsÚwarnÚFutureWarningÚRuntimeWarningr
   r
   r
   r   Úf;   s   r   zignore:f1:FutureWarningc               	   C   sœ   d} t jt| d��  t t¡� tƒ  W d   ƒ n1 sw   Y  W d   ƒ n1 s,w   Y  tjtdd�� tƒ  W d   ƒ d S 1 sGw   Y  d S )NúCaused unexpected warning\(s\)©ÚmatchF©Úraise_on_extra_warnings)ÚpytestÚraisesÚAssertionErrorÚtmÚassert_produces_warningr   r   ©Úmsgr
   r
   r   Ú*test_assert_produces_warning_honors_filter@   s   ÿ€ÿ"ÿr'   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})r,   z^Mes.*\d{2}-\d{3})r,   z\d{2}-\d{3}\s\S+)zMessage, which we do not matchNc                 C   s@   t j| |d�� t || ¡ W d   ƒ d S 1 sw   Y  d S )Nr   ©r#   r$   r   r   )r   Úmessager   r
   r
   r   Ú%test_catch_warning_category_and_matchL   s   "ÿr/   c               	   C   ó–   t } d}d}tjt|d��4 tj| |d�� t d| ¡ t d| ¡ W d   ƒ n1 s,w   Y  W d   ƒ d S W d   ƒ d S 1 sDw   Y  d S )NzDid not see this warningzÇDid 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   Ú	unmatchedr
   r
   r   Ú"test_fail_to_match_runtime_warninga   ó   ÿþÿ"ÿr5   c               	   C   r0   )NÚWarningz³Did not see warning 'FutureWarning' matching 'Warning'. The emitted warning messages are \[FutureWarning\('This is not a match.'\), FutureWarning\('Another unmatched warning.'\)\]r   r1   r2   )r   r    r!   r"   r#   r$   r   r   r3   r
   r
   r   Ú!test_fail_to_match_future_warningp   r6   r8   c               	   C   r0   )Nz\d+z·Did not see warning 'ResourceWarning' matching '\\d\+'. The emitted warning messages are \[ResourceWarning\('This is not a match.'\), ResourceWarning\('Another unmatched warning.'\)\]r   r1   r2   )ÚResourceWarningr    r!   r"   r#   r$   r   r   r3   r
   r
   r   Ú#test_fail_to_match_resource_warning   r6   r:   c              	   C   s†   | \}}d}t jt|d��, t |¡� t d|¡ W d   ƒ n1 s$w   Y  W d   ƒ d S W d   ƒ d S 1 s<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   r
   r
   r   Ú!test_fail_to_catch_actual_warningŽ   s   ÿÿ"ÿr>   c                 C   sT   | \}}t j|dd�� t d|¡ t d|¡ W d   ƒ d S 1 s#w   Y  d S )NFr   úExpected warningzUnexpected warning OKr-   )r   r<   Úextra_categoryr
   r
   r   Útest_ignore_extra_warning–   s
   "þrA   c              	   C   s’   | \}}d}t jt|d��2 t |¡� t d|¡ t d|¡ W d   ƒ n1 s*w   Y  W d   ƒ d S W d   ƒ d S 1 sBw   Y  d S )Nr   r   r?   zUnexpected warning NOT OKr;   )r   r<   r@   r   r
   r
   r   Útest_raise_on_extra_warning�   s   þÿ"ÿrB   c                  C   ó\   t } tj| dd�� t d| ¡ t d| ¡ t d| ¡ W d   ƒ d S 1 s'w   Y  d S )Nú^Match thisr   ú
Match thisúDo not match thatúDo not match that either)ÚUserWarningr#   r$   r   r   ©r   r
   r
   r   Ú1test_same_category_different_messages_first_match¦   ó   "ýrJ   c                  C   rC   )NrD   r   rF   rG   rE   )ÚDeprecationWarningr#   r$   r   r   rI   r
   r
   r   Ú0test_same_category_different_messages_last_match®   rK   rM   c                  C   sT   t tf} tj| dd�� t dt ¡ t dt¡ W d   ƒ d S 1 s#w   Y  d S )NrD   r   rE   zMatch this too)r   rH   r#   r$   r   r   rI   r
   r
   r   Útest_match_multiple_warnings¶   s
   "þrN   c              	   C   s’   | \}}t jtdd��4 tj|dd�� t d|¡ t d|¡ W d   ƒ n1 s*w   Y  W d   ƒ d S W d   ƒ d S 1 sBw   Y  d S )NzDid not see warning.*matchingr   rD   zDo not match itrE   r;   )r   Útarget_categoryÚother_categoryr
   r
   r   Ú&test_right_category_wrong_match_raises¾   s   þÿ"ÿrQ   Úfalse_or_noneFc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestFalseOrNoneExpectedWarningc              	   C   sx   d}t jt|d��) t |¡� tƒ  W d   ƒ n1 sw   Y  W d   ƒ d S W d   ƒ d S 1 s5w   Y  d S )Nr   r   )r    r!   r"   r#   r$   r   )ÚselfrR   r&   r
   r
   r   Útest_raise_on_warningÈ   s   ÿÿ"ÿz4TestFalseOrNoneExpectedWarning.test_raise_on_warningc                 C   s0   t  |¡�	 W d   ƒ d S 1 sw   Y  d S r   )r#   r$   ©rT   rR   r
   r
   r   Útest_no_raise_without_warningÎ   s   "ÿz<TestFalseOrNoneExpectedWarning.test_no_raise_without_warningc                 C   s:   t j|dd�� tƒ  W d   ƒ d S 1 sw   Y  d S )NFr   )r#   r$   r   rV   r
   r
   r   Ú'test_no_raise_with_false_raise_on_extraÒ   s   "ÿzFTestFalseOrNoneExpectedWarning.test_no_raise_with_false_raise_on_extraN)r   Ú
__module__Ú__qualname__rU   rW   rX   r
   r
   r
   r   rS   Æ   s    rS   c               	   C   s  d} t jt| d�� t t¡� t‚1 sw   Y  W d   ƒ n1 s$w   Y  t jt| d�� t t¡�	 t dt	¡ t
‚1 sBw   Y  W d   ƒ n1 sQw   Y  d} t jt| d�� t d ¡�	 t dt	¡ t‚1 sqw   Y  W d   ƒ d S 1 s�w   Y  d S )Nz3Did not see expected warning of class 'UserWarning'r   r   zCaused unexpected warning)r    r!   r"   r#   r$   rH   Ú
ValueErrorr   r   r   Ú
IndexErrorÚSystemErrorr%   r
   r
   r   Útest_raises_during_exception×   s&   ÿÿþÿþ"ÿr^   c                	   C   sº   t jtdd�� t d ¡� tdƒ‚1 sw   Y  W d   ƒ n1 s$w   Y  t jtdd��# tjtdd�� t dt¡ tdƒ‚1 sFw   Y  W d   ƒ d S 1 sVw   Y  d S )NÚErrorr   r   )	r    r!   ÚSyntaxErrorr#   r$   r[   r   r   r   r
   r
   r
   r   Útest_passes_during_exceptioné   s   ÿÿþ"ÿra   )$Ú__doc__r   r    Úpandas.errorsr   r   Úpandas._testingÚ_testingr#   Úfixturer   r9   rH   r   rL   r   r   r   ÚmarkÚfilterwarningsr'   Úparametrizer/   r5   r8   r:   r>   rA   rB   rJ   rM   rN   rQ   rS   r^   ra   r
   r
   r
   r   Ú<module>   sf    ùÿ
	ø
õ



þ
	