U
    42i                     @  s   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 dlmZ d d	lmZ d d
lZdddddZejddddddddZddddddZdddddddZejdddd d!d"d#Zd
S )$    )annotations)	Generator)saferepr)Config)ExitCode)Parser)
FixtureDef)
SubRequest)ScopeNr   None)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   5/tmp/pip-unpacked-wheel-7n2p7kht/_pytest/setuponly.pypytest_addoption   s    
r   T)wrapperzFixtureDef[object]r	   zGenerator[None, object, object])
fixturedefrequestr   c              
   c  sl   z
d V W S |j jjrft|drX| jrLt| jr>| |j}qR| j|j }n|j}|| _t	| |j d X d S )NparamSETUP)
configoption	setupshowhasattridscallabler   Zparam_indexcached_param_show_fixture_action)r   r   r   r   r   r   pytest_fixture_setup   s    



r"   c                 C  s8   | j d k	r4|j}|jjr4t| |jd t| dr4| `d S )NZTEARDOWNr    )Zcached_resultr   r   r   r!   r   r    )r   r   r   r   r   r   pytest_fixture_post_finalizer5   s    

r#   r   str)r   r   msgr   c                 C  s   |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>U   s      z'_show_fixture_action.<locals>.<genexpr>z (fixtures used: {})z, r    [*   )maxsize])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!   @   s.    
r!   )Ztryfirstzint | ExitCode | None)r   r   c                 C  s   | j jrd| j _d S )NT)r   Z	setuponlyr   )r   r   r   r   pytest_cmdline_mainb   s    r>   )
__future__r   typingr   Z_pytest._io.safereprr   Z_pytest.configr   r   Z_pytest.config.argparsingr   Z_pytest.fixturesr   r	   Z_pytest.scoper
   Zpytestr   Zhookimplr"   r#   r!   r>   r   r   r   r   <module>   s    
"
