o
    v&i#'                     @  s   d Z ddlmZ ddl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mZ ddlZG dd dejZd'ddZejddd(ddZd)ddZd*ddZd)d d!Zd+d#d$Zd+d%d&ZdS ),z3Version info, help messages, tracing configuration.    )annotationsN)	Generator)Sequence)Any)Config)ExitCode)	PrintHelp)Parser)TerminalReporterc                      s6   e Zd ZdZddd fddZ	ddddZ  ZS )
HelpActiona2  An argparse Action that will raise a PrintHelp exception in order to skip
    the rest of the argument parsing when --help is passed.

    This prevents argparse from raising UsageError when `--help` is used along
    with 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.

    To opt in to this behavior, the parse caller must set
    `namespace._raise_print_help = True`. Otherwise it just sets the option.
    N)helpoption_stringsSequence[str]deststrr   
str | NonereturnNonec                  s   t  j||ddd|d d S )Nr   TF)r   r   nargsconstdefaultr   )super__init__)selfr   r   r   	__class__ X/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/_pytest/helpconfig.pyr   "   s   
zHelpAction.__init__parserargparse.ArgumentParser	namespaceargparse.Namespacevaluesstr | Sequence[Any] | Noneoption_stringc                 C  s$   t || j| j t|ddrtd S )N_raise_print_helpF)setattrr   r   getattrr   )r   r   r    r"   r$   r   r   r   __call__.   s   zHelpAction.__call__)r   r   r   r   r   r   r   r   )N)
r   r   r    r!   r"   r#   r$   r   r   r   )__name__
__module____qualname____doc__r   r(   __classcell__r   r   r   r   r      s    r   r   r	   r   r   c              	   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 ))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)r1   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`. See also --disable-plugin-autoload.)r1   r   r   metavarr   z--disable-plugin-autoload
store_trueFzDisable plugin auto-loading through entry point packaging metadata. Only plugins explicitly specified in -p or env var PYTEST_PLUGINS will be loaded.)r1   r   r   z--traceconfigz--trace-configz)Trace considerations of conftest.py filesz--debugstore?zpytestdebug.logdebug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.)r1   r   r   r   r5   r   z-oz--override-inioverride_inizhOverride configuration option with "option=value" style, e.g. `-o strict_xfail=True -o cache_dir=cache`.)r   r1   r   )getgroup	addoption
_addoptionr   )r   groupr   r   r   pytest_addoption;   sj   
	

r@   T)wrapperGenerator[None, Config, Config]c               
   #  s    d V   j jrR 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 fd
d} |  S )Nwzutf-8)encodingz@versions pytest-{}, python-{}
invocation_dir={}
cwd={}
args={}

.z$writing pytest debug information to 
r   r   c                     s6      tjdj d  jjd    d S )Nz"wrote pytest debug information to rF   )closesysstderrwriter4   traceroot	setwriterr   config	debugfileundo_tracingr   r   unset_tracing   s   
z+pytest_cmdline_parse.<locals>.unset_tracing)r   r   )optionr9   openrJ   formatpytest__version__joinmapr   rH   version_infoinvocation_paramsdirosgetcwdargsrK   rL   rM   pluginmanagerenable_tracingrI   add_cleanup)pathrR   r   rN   r   pytest_cmdline_parsez   s*   


rd   rO   r   c                 C  sL   t jdtj dtj d t| }|r"|D ]}t j|d  qdS dS )z<Show verbose pytest version installation, including plugins.zThis is pytest version z, imported from rF   N)rH   stdoutrJ   rV   rW   __file__getpluginversioninfo)rO   
plugininfoliner   r   r   show_version_verbose   s   rj   int | ExitCode | Nonec                 C  sD   | j jdkrt|  tjS | j jr |   t|  |   tjS d S )N   )	rS   r0   rj   r   OKr   _do_configureshowhelp_ensure_unconfigure)rO   r   r   r   pytest_cmdline_main   s   rq   c                 C  s  dd l }| jd}|d usJ |j}|| jj  |  |d |  |j	}d}d| }| jj
D ]w}| jj
| \}}	}
|d u rLtd| | d|	 d}|d	|  t|}||d
 kr|  |j||||dd}|D ]}|| qvq6|d|| d   |j||| dd}|r||d  |dd  D ]	}|||  qq6|  |d g d}|D ]\}}|d	|dd|  q|  |  |d |d |d |jdg D ]}|jd|j dd qd S )Nr   terminalreporterzo[pytest] configuration options in the first pytest.toml|pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:    z!help argument cannot be None for z (z):     F)initial_indentsubsequent_indentbreak_on_hyphens   )ry   rl   zEnvironment variables:)	)CIzlWhen set to a non-empty value, pytest knows it is running in a CI process and does not truncate summary info)BUILD_NUMBERzEquivalent to CI)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)PYTEST_DEBUG_TEMPROOTz'Override the system temporary directory)PYTEST_THEMEz)The Pygments style to use for code output)PYTEST_THEME_MODEz3Set the PYTEST_THEME to be either 'dark' or 'light'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)textwrapr`   
get_plugin_twrJ   _parser	optparserformat_helpri   	fullwidth_inidict	TypeErrorlenwrapstatsgetmessage)rO   r   reportertwcolumns
indent_lenindentr4   r   type_defaultspecspec_len	helplinesri   wrappedvarswarningreportr   r   r   ro      sp   


ro   	list[str]c                 C  sd   g }| j  }|r0|d |D ]\}}t|dt|}|j d|j d| }|d|  q|S )Nzregistered third-party plugins:rf   -z at ru   )r`   list_plugin_distinfor2   r'   reprproject_namer0   )rO   linesrh   plugindistloccontentr   r   r   rg     s   

rg   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:rf   z    z<20z: )rS   r9   traceconfigr2   rV   rW   rg   extendr`   list_name_pluginhasattrrf   r   )rO   r   verinfoitemsr4   r   rr   r   r   pytest_report_header  s   



r   )r   r	   r   r   )r   rB   )rO   r   r   r   )rO   r   r   rk   )rO   r   r   r   )r,   
__future__r   argparsecollections.abcr   r   r]   rH   typingr   _pytest.configr   r   r   _pytest.config.argparsingr	   _pytest.terminalr
   rV   Actionr   r@   hookimplrd   rj   rq   ro   rg   r   r   r   r   r   <module>   s.   
&
?
 


S