o
    h                     @   s  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 d dlmZ deddfddZejdddee deded fddZdee ddfddZdee deddfddZejdddedeeee	f  fddZdS )     )	Generator)Optional)UnionN)saferepr)Config)ExitCode)Parser)
FixtureDef)
SubRequest)Scopeparserreturnc                 C   s2   |  d}|jddddd |jdddd	d d S )
Ndebugconfigz--setuponlyz--setup-only
store_truez)Only setup fixtures, do not execute tests)actionhelpz--setupshowz--setup-showz,Show setup of fixtures while executing tests)getgroup	addoption)r   group r   G/var/www/html/ai/venv/lib/python3.10/site-packages/_pytest/setuponly.pypytest_addoption   s   

r   T)hookwrapper
fixturedefrequest)NNNc                 c   sf    d V  |j jjr1t|dr*| jr$t| jr| |j}n
| j|j }n|j}|| _t	| d d S d S )NparamSETUP)
configoption	setupshowhasattridscallabler   param_indexcached_param_show_fixture_action)r   r   r   r   r   r   pytest_fixture_setup   s   


r&   c                 C   sB   | j d ur| jj}|jjrt| d t| dr| `d S d S d S d S )NTEARDOWNr$   )cached_result_fixturemanagerr   r   r   r%   r    r$   )r   r   r   r   r   pytest_fixture_post_finalizer3   s   


r*   msgc                 C   s   | j j}|jd}|r|  | }|  ttt	
| j}|d|  |dj|d| jd  | jd |dkrXtdd	 | jD }|rX|d
d| t| drk|dt| jdd d |  |rw|  d S d S )Ncapturemanagerz  z{step} {scope} {fixture}   r   )stepscopefixturer   c                 s   s    | ]	}|d kr|V  qdS )r   Nr   ).0argr   r   r   	<genexpr>P   s    z'_show_fixture_action.<locals>.<genexpr>z (fixtures used: {})z, r$   [*   )maxsize])r)   r   pluginmanager	getpluginsuspend_global_captureget_terminal_writerlinelistreversedr   index_scopewriteformatljustr/   upperargnamesortedargnamesjoinr    r   r$   flushresume_global_capture)r   r+   r   capmantwscope_indentdepsr   r   r   r%   <   s2   
r%   )tryfirstr   c                 C   s   | j jrd| j _d S )NT)r   	setuponlyr   )r   r   r   r   pytest_cmdline_main]   s   rQ   )typingr   r   r   pytest_pytest._io.safereprr   _pytest.configr   r   _pytest.config.argparsingr   _pytest.fixturesr	   r
   _pytest.scoper   r   hookimplobjectr&   r*   strr%   intrQ   r   r   r   r   <module>   s0    
	
!$