U
    `»{j[  ã                   @  s\  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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 d dlZdddœdd„Zedddddœdd„ƒZdddœdd„Zejddd�ddd œd!d"„ƒZejddd�d#dd$œd%d&„ƒZejdd'�d(dd)œd*d+„ƒZejdd'�d#dd$œd,d-„ƒZejdd'�ddd.œd/d0„ƒZdS )1é    )Úannotations)ÚcontextmanagerN)Ú	Generator)ÚLiteral)Úapply_warning_filters)ÚConfig)Úparse_warning_filter)ÚSession)ÚItem)ÚTerminalReporterr   ÚNone)Ú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/how-to/capture-warnings.html#pytest-mark-filterwarnings )Zaddinivalue_line)r   © r   úO/var/www/html/bwave/python/venv/lib/python3.8/site-packages/_pytest/warnings.pyÚpytest_configure   s    þr   z)Literal[('config', 'collect', 'runtest')]zItem | NonezGenerator[None])r   ÚwhenÚitemr   c                 c  sæ   |   d¡}| jjpg }tjdd��º}|dk	s0t‚tjsRtjdt	d� tjdt
d� t||ƒ |dkrhdn|j}|dk	r¦|jdd�D ]"}|jD ]}	tjt|	d	d
�Ž  qŒq‚z
dV  W 5 |D ]}
|jjt|
||dd�d� q¶X W 5 Q R X 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_messageÚnodeidr   Úlocation)Úkwargs)ZgetiniZknown_args_namespaceZpythonwarningsÚwarningsÚcatch_warningsÚAssertionErrorÚsysÚwarnoptionsr   ÚDeprecationWarningÚPendingDeprecationWarningr   r   Ziter_markersÚargsr   Zpytest_warning_recordedZcall_historicÚdict)r   Úihookr   r   Zconfig_filtersZcmdline_filtersÚlogr   ÚmarkÚargr   r   r   r   Úcatch_warnings_for_item   s0    



üÿr-   zwarnings.WarningMessageÚstr)r   r   c                 C  s¢   | j }t t|ƒ| j| j| j| j¡}| jdk	ržzddl	}W n t
k
rN   Y nPX | | j¡}|dk	r‚d | ¡ ¡}|d|› �7 }nd}|d7 }|d|› d�7 }|S )	z.Convert a warnings.WarningMessage to a string.Nr   Ú
z
Object allocated at:
zPhttps://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warningszDEnable tracemalloc to get traceback where the object was allocated.
zSee z for more info.)Úmessager    Úformatwarningr.   r   ÚfilenameÚlinenoÚlineÚsourceÚtracemallocÚImportErrorÚget_object_tracebackÚjoinÚformat)r   Zwarn_msgÚmsgr6   ÚtbZformatted_tbÚurlr   r   r   Úwarning_record_to_strM   s*    û
r>   T)ÚwrapperZtryfirstr
   zGenerator[None, object, object])r   r   c              
   c  s2   t | j| jd| d�� d V W  5 Q R £ S Q R X d S )NZruntest©r   r)   r   r   )r-   r   r)   )r   r   r   r   Úpytest_runtest_protocolk   s       ÿrA   r	   )Úsessionr   c              
   c  s6   | j }t||jdd d�� d V W  5 Q R £ S Q R X d S )NZcollectr@   ©r   r-   Úhook©rB   r   r   r   r   Úpytest_collections   s       ÿrF   )r?   r   )Úterminalreporterr   c              
   c  s6   | j }t||jdd d�� d V W  5 Q R £ S Q R X d S ©Nr   r@   rC   )rG   r   r   r   r   Úpytest_terminal_summary|   s       ÿrI   c              
   c  s6   | j }t||jdd d�� d V W  5 Q R £ S Q R X d S rH   rC   rE   r   r   r   Úpytest_sessionfinish‡   s       ÿrJ   )Úearly_configr   c              
   c  s0   t | | jdd d�� d V W  5 Q R £ S Q R X d S rH   )r-   rD   )rK   r   r   r   Úpytest_load_initial_conftests�   s       ÿrL   )Ú
__future__r   Ú
contextlibr   r#   Útypingr   r   r    Z_pytest.configr   r   r   Z_pytest.mainr	   Z_pytest.nodesr
   Z_pytest.terminalr   Zpytestr   r-   r>   ZhookimplrA   rF   rI   rJ   rL   r   r   r   r   Ú<module>   s4   1



