a
    !f                     @   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 eddddZejddee eed dddZee ddddZee eddddZejddeeeee	f  d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 )
NZ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)ZgetgroupZ	addoption)r   group r   R/var/www/html/python-backend/venv/lib/python3.9/site-packages/_pytest/setuponly.pypytest_addoption   s    
r   T)Zhookwrapper)NNN)
fixturedefrequestr   c                 c   s`   d V  |j jjr\t|drR| jrFt| jr8| |j}qL| j|j }n|j}|| _t	| d d S )NparamSETUP)
configoption	setupshowhasattrZidscallabler   Zparam_indexcached_param_show_fixture_action)r   r   r   r   r   r   pytest_fixture_setup   s    


r    )r   r   c                 C   s6   | j d ur2| jj}|jjr2t| d t| dr2| `d S )NZTEARDOWNr   )Zcached_result_fixturemanagerr   r   r   r   r   r   )r   r   r   r   r   pytest_fixture_post_finalizer3   s    


r"   )r   msgr   c                 C   s   | j j}|jd}|r |  | }|  ttt	
| j}|d|  |dj|d| jd  | jd |dkrtdd	 | jD }|r|d
d| t| dr|dt| jdd d |  |r|  d S )NZcapturemanagerz  z{step} {scope} {fixture}   r   )stepscopeZfixturer   c                 s   s   | ]}|d kr|V  qdS )r   Nr   ).0argr   r   r   	<genexpr>P       z'_show_fixture_action.<locals>.<genexpr>z (fixtures used: {})z, r   [*   )maxsize])r!   r   ZpluginmanagerZ	getpluginZsuspend_global_captureZget_terminal_writerlinelistreversedr   indexZ_scopewriteformatljustr&   upperargnamesortedargnamesjoinr   r   r   flushZresume_global_capture)r   r#   r   ZcapmanZtwZscope_indentdepsr   r   r   r   <   s0    
r   )Ztryfirst)r   r   c                 C   s   | j jrd| j _d S )NT)r   Z	setuponlyr   )r   r   r   r   pytest_cmdline_main]   s    r=   )typingr   r   r   ZpytestZ_pytest._io.safereprr   Z_pytest.configr   r   Z_pytest.config.argparsingr   Z_pytest.fixturesr	   r
   Z_pytest.scoper   r   Zhookimplobjectr    r"   strr   intr=   r   r   r   r   <module>   s&   
	!
