a
    ˆÏ?e½  ã                   @   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   úT/home/yuhw/wc/wire-cell-python/wcpy/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ÚhasattrÚ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r°t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&   
þ	!
