B
    ”Ü‡\»  ã               @   s¾   d 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	Z	ddl
Z
ddlmZ G dd	„ d	eƒZd
d„ Ze
jdddd„ ƒZdd„ Zdd„ Zdd„ ZdgZdd„ Zdd„ ZdS )z6 version info, help messages, tracing configuration.  é    )Úabsolute_import)Údivision)Úprint_functionN)ÚAction)Ú	PrintHelpc                   s,   e Zd ZdZd‡ fdd„	Zd	dd„Z‡  ZS )
Ú
HelpActiona„  This is 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 t| ƒj||d|d|d d S )NTr   )Úoption_stringsÚdestÚconstÚdefaultÚnargsÚhelp)Úsuperr   Ú__init__)Úselfr   r	   r   r   )Ú	__class__© ú1lib/python3.7/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ÚvaluesZ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   c             C   s†   |   d¡}|j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f |jdddddd |jdddddd d S )NZdebugconfigz	--versionÚ
store_truez2display pytest lib version and import information.)Úactionr   z-hz--helpr   z(show help message and configuration info)r!   r	   r   z-pÚappendZpluginsÚnameznearly-load given plugin (multi-allowed). To avoid loading of plugins, use the `no:` prefix, e.g. `no:doctest`.)r!   r	   r   Úmetavarr   z--traceconfigz--trace-configFz*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+   sH    

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f ¡ ˆ jj ˆj¡ ˆ j ¡ ‰tj 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
c                  s2   ˆ  ¡  tj dˆj ¡ ˆ jj d ¡ ˆƒ  d S )Nz$wrote pytestdebug information to %s
)ÚcloseÚsysÚstderrÚwriter#   ÚtraceÚrootÚ	setwriterr   )ÚconfigÚ	debugfileÚundo_tracingr   r   Úunset_tracingp   s    z+pytest_cmdline_parse.<locals>.unset_tracing)Z
get_resultÚoptionr%   ÚosÚpathÚabspathÚopenr-   ÚpytestÚ__version__ÚpyÚjoinÚmapÚstrr+   Úversion_infoÚgetcwdZ	_origargsr.   r/   r0   ÚpluginmanagerZenable_tracingr,   Zadd_cleanup)Zoutcomer7   r4   r   )r1   r2   r3   r   Úpytest_cmdline_parseZ   s"    

rC   c             C   sR   t j tj¡}tj dtj|f ¡ t	| ƒ}|rNx|D ]}tj |d ¡ q6W d S )Nz,This is pytest version %s, imported from %s
Ú
)
r<   r7   Zlocalr:   Ú__file__r+   r,   r-   r;   Úgetpluginversioninfo)r1   ÚpÚ
plugininfoÚliner   r   r   Úshowversiony   s    
rJ   c             C   s<   | j jrt| ƒ dS | j jr8|  ¡  t| ƒ |  ¡  dS d S )Nr   )r5   ÚversionrJ   r   Z_do_configureÚshowhelpZ_ensure_unconfigure)r1   r   r   r   Úpytest_cmdline_main„   s    rM   c             C   sD  | j  d¡}|j}| | jj ¡ ¡ | ¡  | ¡  | d¡ | ¡  xZ| jjD ]N}| jj	| \}}}|d krrd}d||f }d||f }| |d |j
… ¡ qPW | ¡  | d¡ ddd	d
g}	x"|	D ]\}}| d||f ¡ qÆW | ¡  | ¡  | d¡ | d¡ | d¡ x,|j dg ¡D ]}
|jd|
j dd q"W d S )NZterminalreporterzJ[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:Ústringz%s (%s)z
  %-24s %sz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 internalsz/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)rB   Z
get_pluginZ_twr-   r   Z	optparserZformat_helprI   Z	_ininamesZ_inidictZ	fullwidthZstatsÚgetÚmessage)r1   ZreporterZtwr#   r   Útyper   ÚspecrI   ÚvarsZwarningreportr   r   r   rL      s@    


rL   )Zpytest_pluginszlist of plugin names to loadc             C   sb   g }| j  ¡ }|r^| d¡ x@|D ]8\}}t|dt|ƒƒ}d|j|j|f }| d| ¡ q"W |S )Nzsetuptools registered plugins:rE   z%s-%s at %sz  )rB   Zlist_plugin_distinfor"   r   ÚreprZproject_namerK   )r1   ÚlinesrH   ÚpluginZdistZlocZcontentr   r   r   rF   ¿   s    

rF   c             C   sž   g }| j js| j jr@| dtjtjf ¡ t| ƒ}|r@| |¡ | j jrš| d¡ | j	 
¡ }x<|D ]4\}}t|dƒr||j}nt|ƒ}| d||f ¡ qbW |S )Nzusing: pytest-%s pylib-%szactive plugins:rE   z    %-20s: %s)r5   r%   Ztraceconfigr"   r:   r;   r<   rF   ÚextendrB   Zlist_name_pluginÚhasattrrE   rU   )r1   rV   ZverinfoÚitemsr#   rW   Úrr   r   r   Úpytest_report_headerË   s    



r\   )r   Z
__future__r   r   r   r6   r+   Úargparser   r<   r:   Z_pytest.configr   r   r'   ZhookimplrC   rJ   rM   rL   Zconftest_optionsrF   r\   r   r   r   r   Ú<module>   s$   /-