File: //home/arjun/projects/env/lib/python3.10/site-packages/_pytest/__pycache__/warnings.cpython-310.pyc
o
%we� �
@ s� d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlZd dl m
Z
d dl mZ d dl mZ d d l
mZ d d
lmZ d dlmZ erPd dlmZ d
eddfdd�Zed
edddee ded fdd��Zdejdefdd�Zejddd�deded fdd��Zejddd�deded fdd ��Zejdd!�d"eded fd#d$��Zejdd!�deded fd%d&��Zejdd!�d'd(ded fd)d*��ZdS )+� N)�contextmanager)� Generator)�Optional)�
TYPE_CHECKING)�apply_warning_filters)�Config)�parse_warning_filter)�Session)�Item)�TerminalReporter)�Literal�config�returnc C s | � dd� 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 )�addinivalue_line)r
� r �I/home/arjun/projects/env/lib/python3.10/site-packages/_pytest/warnings.py�pytest_configure s �r �whenz'Literal['config', 'collect', 'runtest']�item)NNNc c s� � | � d�}| jjpg }tjdd��_}|dusJ �tjs*tjdtd� tjdt d� t
||� |du r5dn|j}|durT|jdd�D ]}|j
D ]} tjt| d d
�� qGqBdV |D ]}
|jjt|
||dd�d� qYW d � dS 1 stw Y dS )
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)�getini�known_args_namespace�pythonwarnings�warnings�catch_warnings�sys�warnoptionsr �DeprecationWarning�PendingDeprecationWarningr r �iter_markers�argsr �pytest_warning_recorded�
call_historic�dict)r
�ihookr r �config_filters�cmdline_filters�logr �mark�argr r r r �catch_warnings_for_item s6 �
����"�r5 r c C s� | j }t�t|�| j| j| j| j�}| jdurPzddl }W n
t
y' Y |S w |�| j�}|durBd�|�
� �}|d|� �7 }|S d}|d7 }|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.
zSee z for more info.)�messager$ �
formatwarning�strr �filename�lineno�line�source�tracemalloc�ImportError�get_object_traceback�join�format)r �warn_msg�msgr>