a
    *ñ»jª$  ã                   @  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	mZ ddl	mZ dd	lmZ dd
lmZ ddlZG dd„ deƒZdddœdd„Zejdd�ddœdd„ƒZdddœdd„Zdddœdd„Zdddœdd „Zd!gZdd"dœd#d$„Zdd"dœd%d&„ZdS )'z3Version info, help messages, tracing configuration.é    )Úannotations)ÚAction)Ú	GeneratorN)ÚConfig)ÚExitCode)Ú	PrintHelp)ÚParser)ÚTerminalReporterc                      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__© ú8E:\soccer\ml_env\Lib\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
   r   ÚNone)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� |jdddddd� |jddddd d!d"d#� |jd$d%d&dd'd(� d S ))NZdebugconfigz	--versionz-VÚcountr   ÚversionzoDisplay 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ÚappendÚ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`. See also --disable-plugin-autoload.)r(   r   r   Úmetavarr   z--disable-plugin-autoloadÚ
store_trueFz•Disable plugin auto-loading through entry point packaging metadata. Only plugins explicitly specified in -p or env var PYTEST_PLUGINS will be loaded.)r(   r   r   z--traceconfigz--trace-configz)Trace considerations of conftest.py filesz--debugÚstoreú?zpytestdebug.logÚdebugZDEBUG_FILE_NAMEzšStore internal tracing debug information in this log file. This file is opened with 'w' and truncated as a result, care advised. Default: pytestdebug.log.)r(   r   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/   sj    
ú	ûú
üûùûr2   T)ÚwrapperzGenerator[None, Config, Config]©r%   c               
   #  sª   d V ‰ ˆ j jr¦ˆ j j} t| ddd�‰ˆ d tjd tt	t
jƒ¡ˆ jjt ¡ ˆ jj¡¡ ˆ jj ˆj¡ ˆ j ¡ ‰t
j d| › d�¡ dd	œ‡ ‡‡fd
d„}ˆ  |¡ ˆ S )NÚwzutf-8)Úencodingz@versions pytest-{}, python-{}
invocation_dir={}
cwd={}
args={}

Ú.z$writing pytest debug information to Ú
r$   r4   c                     s6   ˆ  ¡  tj dˆj› d�¡ ˆ jj d ¡ ˆƒ  d S )Nz"wrote pytest debug information to r8   )ÚcloseÚsysÚstderrÚwriter+   ÚtraceÚrootÚ	setwriterr   ©ÚconfigZ	debugfileZundo_tracingr   r   Úunset_tracing„   s    z+pytest_cmdline_parse.<locals>.unset_tracing)Úoptionr0   Úopenr<   ÚformatÚpytestÚ__version__ÚjoinÚmapÚstrr:   Úversion_infoZinvocation_paramsÚdirÚosÚgetcwdÚargsr=   r>   r?   ÚpluginmanagerZenable_tracingr;   Zadd_cleanup)ÚpathrB   r   r@   r   Úpytest_cmdline_parsen   s&    úÿ


rR   r   )rA   r%   c                 C  sl   | j jdkrRtj dtj› dtj› d�¡ t| ƒ}|rh|D ]}tj |d ¡ q:ntj dtj› d�¡ d S )Né   zThis is pytest version z, imported from r8   zpytest )	rC   r'   r:   Ústdoutr<   rF   rG   Ú__file__Úgetpluginversioninfo)rA   Ú
plugininfoÚliner   r   r   Úshowversion�   s    ÿrY   zint | ExitCode | Nonec                 C  s@   | j jdkrt| ƒ dS | j jr<|  ¡  t| ƒ |  ¡  dS d S )Nr   )rC   r'   rY   r   Z_do_configureÚshowhelpZ_ensure_unconfigure)rA   r   r   r   Úpytest_cmdline_mainœ   s    r[   c                 C  s  dd l }| j d¡}|d us J ‚|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üql| d|| d  ¡ |j||| dd�}|rl| |d ¡ |dd … D ]}| || ¡ �qVql| ¡  | d¡ g d¢}|D ]"\}}| d
|d›d|› �¡ �qŒ| ¡  | ¡  | d¡ | d¡ | d¡ |j dg ¡D ]}|jd|j dd� �qìd S )Nr   ZterminalreporterzY[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:é   ú Ústringz!help argument cannot be None for z (z):ú  é   F)Úinitial_indentÚsubsequent_indentÚbreak_on_hyphensé   )rc   rS   zEnvironment variables:))ÚCIzmWhen set (regardless of value), pytest knows it is running in a CI process and does not truncate summary info)ZBUILD_NUMBERzEquivalent to CI)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<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)Úred)ÚtextwraprP   Z
get_pluginZ_twr<   r   Z	optparserÚformat_helprX   Z	fullwidthZ	_ininamesZ_inidictÚ	TypeErrorÚlenÚwrapÚstatsÚgetÚmessage)rA   rh   ÚreporterZtwÚcolumnsZ
indent_lenÚindentr+   r   Útyper   ÚspecZspec_lenZ	helplinesrX   ÚwrappedÚvarsZwarningreportr   r   r   rZ   ¨   sn    ÿÿû


ÿrZ   )Zpytest_pluginszlist of plugin names to loadz	list[str]c                 C  sd   g }| j  ¡ }|r`| d¡ |D ]>\}}t|dt|ƒƒ}|j› d|j› d|› �}| d| ¡ q |S )Nzregistered third-party plugins:rU   ú-z at r_   )rP   Zlist_plugin_distinfor)   r   ÚreprÚproject_namer'   )rA   ÚlinesrW   ÚpluginÚdistÚlocÚcontentr   r   r   rV   ý   s    

rV   c                 C  sœ   g }| j js| j jr<| dtj› �¡ t| ƒ}|r<| |¡ | j jr˜| d¡ | j 	¡ }|D ]:\}}t
|dƒrv|j}nt|ƒ}| d|d›d|› �¡ q\|S )Nzusing: pytest-zactive plugins:rU   z    z<20z: )rC   r0   Ztraceconfigr)   rF   rG   rV   ÚextendrP   Zlist_name_pluginÚhasattrrU   rx   )rA   rz   ZverinfoÚitemsr+   r{   Úrr   r   r   Úpytest_report_header	  s    



rƒ   )r"   Ú
__future__r   Úargparser   Úcollections.abcr   rM   r:   Z_pytest.configr   r   r   Z_pytest.config.argparsingr   Z_pytest.terminalr	   rF   r
   r2   ZhookimplrR   rY   r[   rZ   Zconftest_optionsrV   rƒ   r   r   r   r   Ú<module>   s*   ?
 R