a
    /§»a—   ã                   @   s&  d Z ddl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	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 G dd„ deƒZeddœdd„Ze
jdd�dd„ ƒZeddœdd„Zeeeeef  dœdd„Zeddœdd„ZdgZeee dœdd„Zeee dœdd„ZdS ) z3Version info, help messages, tracing configuration.é    N)ÚAction)ÚList)ÚOptional)ÚUnion)ÚConfig)ÚExitCode)Ú	PrintHelp)ÚParserc                       s,   e Zd ZdZd‡ fdd„	Zd	dd„Z‡  ZS )
Ú
HelpActiona}  An argparse Action that will raise an exception in order to skip the
    rest of the argument parsing when --help is passed.

    This prevents argparse from quitting due to missing required arguments
    when any are defined, for example by ``pytest_addoption``.
    This is similar to the way that the builtin argparse --help option is
    implemented by raising SystemExit.
    NFc                    s   t ƒ j||d|d|d� d S )NTr   )Úoption_stringsÚdestÚconstÚdefaultÚnargsÚhelp)ÚsuperÚ__init__)Úselfr   r   r   r   ©Ú	__class__© úL/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/_pytest/helpconfig.pyr      s    úzHelpAction.__init__c                 C   s&   t || j| jƒ t|jddƒr"t‚d S )NZafter_preparseF)Úsetattrr   r   ÚgetattrÚ_parserr   )r   ÚparserÚ	namespaceÚvaluesÚoption_stringr   r   r   Ú__call__&   s    zHelpAction.__call__)NFN)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r   r   r
      s   	
r
   )r   Úreturnc                 C   sŠ   |   d¡}|jddddddd� |jd	d
tddd� |jdddg ddd� |jdddddd� |jdddddd� |jddd dd!d"� d S )#NZdebugconfigz	--versionz-VÚcountr   Úversionzndisplay pytest version and information about plugins.When given twice, also display information about plugins.)Úactionr   r   r   z-hz--helpr   z(show help message and configuration info)r(   r   r   z-pÚappendZpluginsÚnamez‰early-load given plugin module name or entry point (multi-allowed).
To avoid loading of plugins, use the `no:` prefix, e.g. `no:doctest`.)r(   r   r   Úmetavarr   z--traceconfigz--trace-configÚ
store_trueFz*trace considerations of conftest.py files.)r(   r   r   z--debugÚdebugz>store internal tracing debug information in 'pytestdebug.log'.)r(   r   r   r   z-oz--override-iniZoverride_iniz^override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`.)r   r(   r   )ZgetgroupZ	addoptionZ
_addoptionr
   )r   Úgroupr   r   r   Úpytest_addoption.   sZ    
ú	ûú
ûûûr/   T)Zhookwrapperc               
   #   s¬   d V } |   ¡ ‰ ˆ jjr¨tj d¡}t|dƒ‰ˆ dtj	t
j	d tttjƒ¡t ¡ ˆ jjf ¡ ˆ jj ˆj¡ ˆ j ¡ ‰tj d| ¡ d dœ‡ ‡‡fdd„}ˆ  |¡ d S )	Nzpytestdebug.logÚwz5versions pytest-%s, py-%s, python-%s
cwd=%s
args=%s

Ú.z&writing pytestdebug information to %s
)r%   c                      s2   ˆ  ¡  tj dˆj ¡ ˆ jj d ¡ ˆƒ  d S )Nz$wrote pytestdebug information to %s
)ÚcloseÚsysÚstderrÚwriter*   ÚtraceÚrootÚ	setwriterr   ©ÚconfigZ	debugfileZundo_tracingr   r   Úunset_tracingw   s    z+pytest_cmdline_parse.<locals>.unset_tracing)Z
get_resultÚoptionr-   ÚosÚpathÚabspathÚopenr5   ÚpytestÚ__version__ÚpyÚjoinÚmapÚstrr3   Úversion_infoÚgetcwdZinvocation_paramsÚargsr6   r7   r8   ÚpluginmanagerZenable_tracingr4   Zadd_cleanup)Úoutcomer>   r;   r   r9   r   Úpytest_cmdline_parsea   s(    
ûþÿ
rL   )r:   r%   c                 C   sf   | j jdkrLtj d tjtj¡¡ t	| ƒ}|rb|D ]}tj |d ¡ q4ntj dtj› d�¡ d S )Né   z,This is pytest version {}, imported from {}
Ú
zpytest )
r<   r'   r3   r4   r5   ÚformatrA   rB   Ú__file__Úgetpluginversioninfo)r:   Ú
plugininfoÚliner   r   r   Úshowversion€   s    ÿÿrT   c                 C   s@   | j jdkrt| ƒ dS | j jr<|  ¡  t| ƒ |  ¡  dS d S )Nr   )r<   r'   rT   r   Z_do_configureÚshowhelpZ_ensure_unconfigure)r:   r   r   r   Úpytest_cmdline_main�   s    rV   c                 C   sú  dd l }| j d¡}|j}| | jj ¡ ¡ | ¡  | d¡ | ¡  |j	}d}d| }| jj
D ]ú}| jj| \}}	}
|	d u r‚d}	|d u r˜td|› �ƒ‚|› d|	› d	�}| d
| ¡ t|ƒ}||d krü| ¡  |j||||dd�}|D ]}| |¡ qêq`| d|| d  ¡ |j||| dd�}|r`| |d ¡ |dd … D ]}| || ¡ �qDq`| ¡  | d¡ g d¢}|D ]"\}}| d|d›d|› �¡ �qz| ¡  | ¡  | d¡ | d¡ | d¡ |j dg ¡D ]}|jd|j dd� �qÚd S )Nr   ZterminalreporterzJ[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:é   ú Ústringz!help argument cannot be None for z (z):z  %sé   F)Úinitial_indentÚsubsequent_indentÚbreak_on_hyphensé   )r]   rM   zenvironment variables:))ZPYTEST_ADDOPTSzextra command line options)ZPYTEST_PLUGINSz.comma-separated plugins to load during startup)ZPYTEST_DISABLE_PLUGIN_AUTOLOADz"set to disable plugin auto-loading)ZPYTEST_DEBUGz1set to enable debug tracing of pytest's internalsú  z<24z/to see available markers type: pytest --markersz1to see available fixtures type: pytest --fixtureszˆ(shown according to specified file_or_dir or current dir if not specified; fixtures with leading '_' are only shown with the '-v' optionÚwarningsz
warning : T)Zred)ÚtextwraprJ   Z
get_pluginZ_twr5   r   Z	optparserÚformat_helprS   Z	fullwidthZ	_ininamesZ_inidictÚ	TypeErrorÚlenÚwrapÚstatsÚgetÚmessage)r:   ra   ZreporterZtwÚcolumnsZ
indent_lenÚindentr*   r   Útyper   ÚspecZspec_lenZ	helplinesrS   ÚwrappedÚvarsZwarningreportr   r   r   rU   ›   sj    ÿû


ÿrU   )Zpytest_pluginszlist of plugin names to loadc                 C   sd   g }| j  ¡ }|r`| d¡ |D ]>\}}t|dt|ƒƒ}|j› d|j› d|› �}| d| ¡ q |S )Nzsetuptools registered plugins:rP   ú-z at r_   )rJ   Zlist_plugin_distinfor)   r   ÚreprÚproject_namer'   )r:   ÚlinesrR   ÚpluginÚdistÚlocÚcontentr   r   r   rQ   ç   s    

rQ   c                 C   s¤   g }| j js| j jrD| dtj› dtj› �¡ t| ƒ}|rD| |¡ | j jr | d¡ | j	 
¡ }|D ]:\}}t|dƒr~|j}nt|ƒ}| d|d›d|› �¡ qd|S )Nzusing: pytest-z pylib-zactive plugins:rP   z    z<20z: )r<   r-   Ztraceconfigr)   rA   rB   rC   rQ   ÚextendrJ   Zlist_name_pluginÚhasattrrP   rp   )r:   rr   ZverinfoÚitemsr*   rs   Úrr   r   r   Úpytest_report_headeró   s    



r{   )r#   r=   r3   Úargparser   Útypingr   r   r   rC   rA   Z_pytest.configr   r   r   Z_pytest.config.argparsingr	   r
   r/   ZhookimplrL   rT   ÚintrV   rU   Zconftest_optionsrF   rQ   r{   r   r   r   r   Ú<module>   s,   3

I