a
    ܌xdH!                     @   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
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__ J/var/www/html/Ranjet/env/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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namezEarly-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store?zpytestdebug.logdebugZDEBUG_FILE_NAMEzStore 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,   s^    
	
r2   T)Zhookwrapperc               	   #   s   d V } |     jjr jj}t|dd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 )Nwz.versions pytest-%s, python-%s
cwd=%s
args=%s

.z'writing pytest debug information to %s
)r%   c                      s2      tjdj   jjd    d S )Nz%wrote pytest debug information to %s
)closesysstderrwriter+   traceroot	setwriterr   configZ	debugfileZundo_tracingr   r   unset_tracing{   s    z+pytest_cmdline_parse.<locals>.unset_tracing)Z
get_resultoptionr0   openr8   pytest__version__joinmapstrr6   version_infoosgetcwdZinvocation_paramsargsr9   r:   r;   pluginmanagerZenable_tracingr7   Zadd_cleanup)outcomepathr>   r   r<   r   pytest_cmdline_parsed   s&    


rM   )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'   r6   stdoutr8   formatrA   rB   __file__getpluginversioninfo)r=   
plugininfoliner   r   r   showversion   s    rV   c                 C   s@   | j jdkrt|  dS | j jr<|   t|  |   dS d S )Nr   )r?   r'   rV   r   Z_do_configureshowhelpZ_ensure_unconfigure)r=   r   r   r   pytest_cmdline_main   s    rX   c                 C   s  dd l }| jd}|j}|| jj  |  |d |  |j	}d}d| }| jj
D ]}| jj| \}}	}
|	d u rd}	|d u rtd| | d|	 d	}|d
|  t|}||d kr|  |j||||dd}|D ]}|| qq`|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 qd 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):z  %s   F)initial_indentsubsequent_indentbreak_on_hyphens   )r_   rN   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)red)textwraprJ   Z
get_pluginZ_twr8   r   Z	optparserformat_helprU   Z	fullwidthZ	_ininamesZ_inidict	TypeErrorlenwrapstatsgetmessage)r=   rd   reporterZtwcolumnsZ
indent_lenindentr+   r   typer   specZspec_lenZ	helplinesrU   wrappedvarsZwarningreportr   r   r   rW      sj    


rW   )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:rR   -z at ra   )rJ   Zlist_plugin_distinfor)   r   reprproject_namer'   )r=   linesrT   plugindistloccontentr   r   r   rS      s    

rS   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:rR   z    z<20z: )r?   r0   Ztraceconfigr)   rA   rB   rS   extendrJ   Zlist_name_pluginhasattrrR   rt   )r=   rv   Zverinfoitemsr+   rw   rr   r   r   pytest_report_header   s    



r   )r#   rG   r6   argparser   typingr   r   r   rA   Z_pytest.configr   r   r   Z_pytest.config.argparsingr	   r
   r2   ZhookimplrM   rV   intrX   rW   Zconftest_optionsrE   rS   r   r   r   r   r   <module>   s*   8

J