o
    Ú­jÒ!  ã                   @   s6  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 ddlmZ G dd„ deƒZdeddfdd„Ze	jdd�dd„ ƒZdeddfdd„Zdedeeeef  fdd„Zdeddfdd„ZdgZdedee fdd„Zdedee fd d!„ZdS )"z3Version info, help messages, tracing configuration.é    N)ÚAction)ÚList)ÚOptional)ÚUnion)Ú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__© úO/var/www/html/CropPilot/venv/lib/python3.10/site-packages/_pytest/helpconfig.pyr      s   
úzHelpAction.__init__c                 C   s&   t || j| jƒ t|jddƒrt‚d S )NÚ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 )'NÚ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`.)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ÚdebugÚ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-iniÚoverride_iniz^Override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`.)r   r+   r   )ÚgetgroupÚ	addoptionÚ
_addoptionr   )r   Úgroupr   r   r   Úpytest_addoption-   s^   
ú	ûú
ûù
ûr:   T)Úhookwrapperc               	   #   sª   � d V } |   ¡ ‰ ˆ jjrSˆ jj}t|ddd�‰ˆ dtjd tt	t
jƒ¡t ¡ ˆ jjf ¡ ˆ jj ˆj¡ ˆ j ¡ ‰t
j d| ¡ d
‡ ‡‡fdd	„}ˆ  |¡ d S d S )NÚwzutf-8)Úencodingz.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   ©ÚconfigÚ	debugfileÚundo_tracingr   r   Úunset_tracing|   s   
z+pytest_cmdline_parse.<locals>.unset_tracing)r'   N)Ú
get_resultÚoptionr3   ÚopenrB   ÚpytestÚ__version__ÚjoinÚmapÚstrr@   Úversion_infoÚosÚgetcwdÚinvocation_paramsÚargsrC   rD   rE   ÚpluginmanagerÚenable_tracingrA   Úadd_cleanup)ÚoutcomeÚpathrJ   r   rF   r   Úpytest_cmdline_parsee   s*   €üþÿ

èr]   rG   c                 C   sl   | j jdkr)tj d tjtj¡¡ t	| ƒ}|r%|D ]}tj |d ¡ qd S d S tj dtj› d�¡ d S )Né   z,This is pytest version {}, imported from {}
Ú
zpytest )
rL   r*   r@   ÚstdoutrB   ÚformatrN   rO   Ú__file__Úgetpluginversioninfo)rG   Ú
plugininfoÚliner   r   r   Úshowversion…   s   ÿÿþrf   c                 C   s@   | j jdkrt| ƒ dS | j jr|  ¡  t| ƒ |  ¡  dS d S )Nr   )rL   r*   rf   r   Ú_do_configureÚshowhelpÚ_ensure_unconfigure)rG   r   r   r   Úpytest_cmdline_main”   s   rj   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 rGd}	|d u rRtd|› �ƒ‚|› d|	› d	�}| d
| ¡ t|ƒ}||d kr„| ¡  |j||||dd�}|D ]}| |¡ q{q6| d|| d  ¡ |j||| dd�}|r²| |d ¡ |dd … D ]	}| || ¡ q¨q6| ¡  | d¡ g d¢}|D ]\}}| d|d›d|› �¡ qÂ| ¡  | ¡  | d¡ | d¡ | d¡ |j dg ¡D ]}|jd|j dd� qñd S )Nr   Ú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é   )rr   r^   zEnvironment variables:))ÚPYTEST_ADDOPTSzExtra command line options)ÚPYTEST_PLUGINSz.Comma-separated plugins to load during startup)ÚPYTEST_DISABLE_PLUGIN_AUTOLOADz"Set to disable plugin auto-loading)Ú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)ÚtextwraprX   Ú
get_pluginÚ_twrB   r   Ú	optparserÚformat_helpre   Ú	fullwidthÚ	_ininamesÚ_inidictÚ	TypeErrorÚlenÚwrapÚstatsÚgetÚmessage)rG   r{   ÚreporterÚtwÚcolumnsÚ
indent_lenÚindentr.   r   Útyper   ÚspecÚspec_lenÚ	helplinesre   ÚwrappedÚvarsÚwarningreportr   r   r   rh       st   ÿÿûÿ€


ÿrh   )Úpytest_pluginszlist of plugin names to loadc                 C   sd   g }| j  ¡ }|r0| d¡ |D ]\}}t|dt|ƒƒ}|j› d|j› d|› �}| d| ¡ q|S )Nzsetuptools registered plugins:rb   ú-z at rx   )rX   Úlist_plugin_distinfor,   r   ÚreprÚproject_namer*   )rG   Úlinesrd   ÚpluginÚdistÚlocÚcontentr   r   r   rc   ð   s   

rc   c                 C   sœ   g }| j js
| j jr| dtj› �¡ t| ƒ}|r| |¡ | j jrL| d¡ | j 	¡ }|D ]\}}t
|dƒr;|j}nt|ƒ}| d|d›d|› �¡ q.|S )Nzusing: pytest-zactive plugins:rb   z    z<20z: )rL   r3   Útraceconfigr,   rN   rO   rc   ÚextendrX   Úlist_name_pluginÚhasattrrb   r˜   )rG   rš   ÚverinfoÚitemsr.   r›   Úrr   r   r   Úpytest_report_headerü   s   



r¦   )r%   rT   r@   Úargparser   Útypingr   r   r   rN   Ú_pytest.configr   r   r   Ú_pytest.config.argparsingr	   Ú_pytest.terminalr
   r   r:   Úhookimplr]   rf   Úintrj   rh   Úconftest_optionsrR   rc   r¦   r   r   r   r   Ú<module>   s.    
8
M