a
    /§»aˆ  ã                   @   sŠ  d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
 d dl	mZ d dl	mZ d d	lmZ d d
lmZ d dlmZ er d dlmZ eddœdd„Zeedee ed dœdd„ƒZejedœdd„Zejddd�eed dœdd„ƒZejddd�eed dœdd„ƒZejdd �eed d!œd"d#„ƒZejdd �eed dœd$d%„ƒZejdd �d&ed d'œd(d)„ƒZdS )*é    N)Úcontextmanager)Ú	Generator)ÚOptional)ÚTYPE_CHECKING)Úapply_warning_filters)ÚConfig)Úparse_warning_filter)ÚSession)ÚItem)ÚTerminalReporter)ÚLiteral)ÚconfigÚreturnc                 C   s   |   dd¡ d S )NÚmarkersz�filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/warnings.html#pytest-mark-filterwarnings )Zaddinivalue_line)r   © r   úJ/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/_pytest/warnings.pyÚpytest_configure   s    þr   z'Literal['config', 'collect', 'runtest'])NNN)r   ÚwhenÚitemr   c              	   c   s  |   d¡}| jjpg }tjdd��Ö}|dus0J ‚tjsRtjdtd� tjdt	d� t
||ƒ |du rhdn|j}|dur¦|jdd�D ]"}|jD ]}	tjt|	d	d
�Ž  qŒq‚dV  |D ]8}
|jjt|
||dd�d� |jjt|
||dd�d� q°W d  ƒ n1 sþ0    Y  dS )zíContext manager that catches warnings generated in the contained execution block.

    ``item`` can be None if we are not in the context of an item execution.

    Each warning captured triggers the ``pytest_warning_recorded`` hook.
    ÚfilterwarningsT)ÚrecordNÚalways)ÚcategoryÚ )ÚnameF)Úescape)Úwarning_messager   r   Úlocation)Úkwargs)r   Únodeidr   r   )ZgetiniZknown_args_namespaceZpythonwarningsÚwarningsÚcatch_warningsÚsysÚwarnoptionsr   ÚDeprecationWarningÚPendingDeprecationWarningr   r   Ziter_markersÚargsr   Zpytest_warning_capturedZcall_historicÚdictZpytest_warning_recorded)r   Úihookr   r   Zconfig_filtersZcmdline_filtersÚlogr   ÚmarkÚargr   r   r   r   Úcatch_warnings_for_item   s>    


üÿüÿr,   )r   r   c                 C   s(   | j }t t|ƒ| j| j| j| j¡}|S )z.Convert a warnings.WarningMessage to a string.)Úmessager    ÚformatwarningÚstrr   ÚfilenameÚlinenoÚline)r   Zwarn_msgÚmsgr   r   r   Úwarning_record_to_strR   s    ûr4   T)ÚhookwrapperZtryfirst)r   r   c                 c   s>   t | j| jd| d�� d V  W d   ƒ n1 s00    Y  d S )NZruntest©r   r(   r   r   )r,   r   r(   )r   r   r   r   Úpytest_runtest_protocol_   s    ÿr7   )Úsessionr   c                 c   sB   | j }t||jdd d�� d V  W d   ƒ n1 s40    Y  d S )NZcollectr6   ©r   r,   Úhook©r8   r   r   r   r   Úpytest_collectiong   s
    
ÿr<   )r5   )Úterminalreporterr   c                 c   sB   | j }t||jdd d�� d V  W d   ƒ n1 s40    Y  d S ©Nr   r6   r9   )r=   r   r   r   r   Úpytest_terminal_summaryp   s
    
ÿr?   c                 c   sB   | j }t||jdd d�� d V  W d   ƒ n1 s40    Y  d S r>   r9   r;   r   r   r   Úpytest_sessionfinish{   s
    
ÿr@   r   )Úearly_configr   c                 c   s<   t | | jdd d�� d V  W d   ƒ n1 s.0    Y  d S r>   )r,   r:   )rA   r   r   r   Úpytest_load_initial_conftests„   s    
ÿrB   ) r"   r    Ú
contextlibr   Útypingr   r   r   ZpytestZ_pytest.configr   r   r   Z_pytest.mainr	   Z_pytest.nodesr
   Z_pytest.terminalr   Ztyping_extensionsr   r   r,   ÚWarningMessager/   r4   Zhookimplr7   r<   r?   r@   rB   r   r   r   r   Ú<module>   sH   û5
þ


þ