o
    rh[                     @  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d2ddZed3ddZd4ddZejdddd5d"d#Zejdddd6d&d'Zejdd(d7d+d,Zejdd(d8d-d.Zejdd(d9d0d1ZdS ):    )annotations)contextmanagerN)	Generator)Literal)apply_warning_filters)Config)parse_warning_filter)Session)Item)TerminalReporterconfigr   returnNonec                 C  s   |  dd d S )Nmarkerszfilterwarnings(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   N/var/www/html/alpaca_bot/venv/lib/python3.10/site-packages/_pytest/warnings.pypytest_configure   s   r   when'Literal['config', 'collect', 'runtest']itemItem | NoneGenerator[None]c                 c  s"   |  d}| jjpg }tjddu}|dusJ tjs*tjdtd tjdt	d t
|| |du r5dn|j}|durT|jddD ]}|jD ]}	tjt|	d	d
  qGqBzdV  W |D ]}
|jjt|
||ddd q[n|D ]}
|jjt|
||ddd qnw W d   dS 1 sw   Y  dS )zContext 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   sJ   



"r8   r    warnings.WarningMessagestrc                 C  s   | j }tt|| j| j| j| j}| jdurPzddl	}W n
 t
y'   Y |S w || j}|durBd| }|d| 7 }|S 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    warn_msgmsgrB   tbformatted_tburlr   r   r   warning_record_to_strM   s0   
rL   T)wrappertryfirstr
   Generator[None, object, object]c                 c  s@    t | j| jd| d d V W  d    S 1 sw   Y  d S )Nruntestr   r2   r   r   )r8   r   r2   )r   r   r   r   pytest_runtest_protocolk   s   $rR   sessionr	   c                 c  D    | j }t||jdd d d V W  d    S 1 sw   Y  d S )NcollectrQ   r   r8   hookrS   r   r   r   r   pytest_collections      
$rY   )rM   terminalreporterr   c                 c  rT   Nr   rQ   rV   )r[   r   r   r   r   pytest_terminal_summary|   s   
$r]   c                 c  rT   r\   rV   rX   r   r   r   pytest_sessionfinish   rZ   r^   early_configc                 c  s>    t | | jdd d d V W  d    S 1 sw   Y  d S r\   )r8   rW   )r_   r   r   r   pytest_load_initial_conftests   s   
$r`   )r   r   r   r   )r   r   r   r   r   r   r   r   )r    r9   r   r:   )r   r
   r   rO   )rS   r	   r   rO   )r[   r   r   r   )rS   r	   r   r   )r_   r   r   r   )
__future__r   
contextlibr   r)   typingr   r   r'   _pytest.configr   r   r   _pytest.mainr	   _pytest.nodesr
   _pytest.terminalr   pytestr   r8   rL   hookimplrR   rY   r]   r^   r`   r   r   r   r   <module>   s6   

1



