U
    `»{jõ ã                   @  s¸  d Z ddlmZ ddlZddlZddl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ZddlZddlZddlZddlZddl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 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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-m.Z. ddl/m0Z0 ddl/m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6Z4ddl6m7Z7 dd l6m8Z8 dd!l9m:Z: dd"l;m<Z< dd#l=m>Z> dd$l=m?Z? ddl@Z4ddlAZ4dd%lBmCZC dd&lBmDZD dd'lEmFZF dd(lEmGZG dd)lEmHZH dd*lEmIZI dd+lEmJZJ dd,lEmKZK dd-lLmMZM dd.lNmOZO dd/lNmPZP e%�rÊdd0lQmRZR dd1lSmTZT eUZVe(d2ƒZWe*d2ƒZXeG d3d4„ d4ejYƒƒZZG d5d6„ d6e[ƒZ\d7d8d9œd:d;„Z]d¤d<d=d>d?œd@dA„Z^dBdCœdDdE„Z_G dFdG„ dGƒZ`dHdHdHdIœdJdK„ZadHdHdHdIœdLdM„ZbdNZcecd¥˜ZdeeedƒZfef gdi¡ ef gdj¡ d¦dkd=dld?œdmdn„ZhdodCœdpdq„Zid§d<d=dld?œdrds„Zjdtdtduœdvdw„ZkdxdHdydzd{œd|d}„ZleG d~do„ doe,ƒƒZmdd€d�œd‚dƒ„ZnG d„d…„ d…ƒZoeoƒ Zpd†d‡dˆœd‰dŠ„ZqeG d‹dl„ dlƒƒZrd8dCœdŒd�„Zsd¨dldŽd�d�œd‘d’„ZtdHd8d“œd”d•„Zue
d–d—�dHd8d˜d™œdšd›„ƒZvdHdœd�œdždŸ„Zwd†d†d d¡œd¢d£„ZxdS )©z:Command line options, ini-file and conftest.py processing.é    )ÚannotationsN)Ú	lru_cache)Údedent)ÚFunctionType)ÚAny)ÚCallable)Úcast)ÚFinal)Úfinal)Ú	Generator)ÚIO)ÚIterable)ÚIterator)ÚSequence)ÚTextIO)ÚType)ÚTYPE_CHECKING)ÚHookimplMarker)ÚHookimplOpts)ÚHookspecMarker)ÚHookspecOpts)ÚPluginManageré   )ÚPathAwareHookProxy)Ú	PrintHelp)Ú
UsageError)Údetermine_setup)Ú__version__)ÚExceptionInfo)Úfilter_traceback)ÚTracebackStyle)ÚTerminalWriter)ÚArgument©ÚParser)Úfail)ÚSkipped)Úabsolutepath)Úbestrelpath)Úimport_path)Ú
ImportMode)Úresolve_package_path)Úsafe_exists)ÚStash)ÚPytestConfigWarning)Úwarn_explicit_for)ÚCache)ÚTerminalReporterÚpytestc                   @  s(   e Zd ZdZdZdZdZdZdZdZ	dS )	ÚExitCodez�Encodes the valid exit codes by pytest.

    Currently users and plugins may supply other exit codes as well.

    .. versionadded:: 5.0
    r   r   é   é   é   é   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚOKZTESTS_FAILEDZINTERRUPTEDÚINTERNAL_ERRORÚUSAGE_ERRORZNO_TESTS_COLLECTED© r?   r?   úV/var/www/html/bwave/python/venv/lib/python3.8/site-packages/_pytest/config/__init__.pyr3   [   s   r3   c                   @  s,   e Zd Zddddœdd„Zddœd	d
„ZdS )ÚConftestImportFailureúpathlib.PathÚ	ExceptionÚNone)ÚpathÚcauseÚreturnc                C  s   || _ || _d S ©N)rE   rF   )ÚselfrE   rF   r?   r?   r@   Ú__init__s   s    zConftestImportFailure.__init__Ústr©rG   c                 C  s"   t | jƒj› d| j› d| j› d�S )Nú: z (from ú))ÚtyperF   r8   rE   ©rI   r?   r?   r@   Ú__str__|   s    zConftestImportFailure.__str__N)r8   r9   r:   rJ   rQ   r?   r?   r?   r@   rA   r   s   	rA   z_pytest._code.TracebackEntryÚbool)ÚentryrG   c                 C  s   t | ƒodt| jƒ tj¡kS )zÓFilter tracebacks entries which point to pytest internals or importlib.

    Make a special case for importlib because we use it to import test modules and conftest files
    in _pytest.pathlib.import_path.
    Ú	importlib)r   rK   rE   ÚsplitÚosÚsep)rS   r?   r?   r@   Ú,filter_traceback_for_conftest_import_failure€   s    rX   z#list[str] | os.PathLike[str] | Noneú$Sequence[str | _PluggyPlugin] | Nonezint | ExitCode)ÚargsÚpluginsrG   c              
   C  sÊ  t j d¡}�z��z(tt jd< zt| |ƒ}W n² tk
rÞ } z”t |j	¡}t
tjƒ}|jd|j› d�dd� |j t¡|_|jrŽ|jddd	�n| ¡ }t|ƒ}| ¡ D ]}	|j|	 ¡ dd� q¦tj W Y ¢W W ¢ÐS d}~X Y nZX zL|jj|d
�}
zt|
ƒW W ¢0W W ¢œS  tk
�r(   |
 Y W ¢W W ¢zS X W 5 | ¡  X W n` tk
�rš } z@t
tjƒ}|jD ]}|jd|› d�dd� �q^tj W Y ¢W ¢S d}~X Y nX W 5 |dk�rºt j dd¡ n
|t jd< X dS )aL  Perform an in-process test run.

    :param args:
        List of command line arguments. If `None` or not given, defaults to reading
        arguments directly from the process command line (:data:`sys.argv`).
    :param plugins: List of plugin objects to be auto-registered during initialization.

    :returns: An exit code.
    ZPYTEST_VERSIONNz$ImportError while loading conftest 'z'.T)ÚredÚshortF)ÚstyleÚchain©ÚconfigzERROR: Ú
)rV   ÚenvironÚgetÚpopr   Ú_prepareconfigrA   r   Úfrom_exceptionrF   r!   ÚsysÚstderrÚlinerE   Ú	tracebackÚfilterrX   ÚgetreprZexconlyrK   Ú
splitlinesÚrstripr3   r>   Ú_ensure_unconfigureÚhookZpytest_cmdline_mainÚ
ValueErrorr   rZ   )rZ   r[   Zold_pytest_versionra   ÚeÚexc_infoÚtwZexc_reprZformatted_tbrj   ÚretÚmsgr?   r?   r@   Úmain‹   sF    

ÿÿý"

$
rx   ÚintrL   c                  C  sT   zt ƒ } tj ¡  | W S  tk
rN   t tjtj¡}t 	|tj 
¡ ¡ Y dS X dS )zoThe CLI entry point of pytest.

    This function is not meant for programmable use; use `main()` instead.
    r   N)rx   rh   ÚstdoutÚflushÚBrokenPipeErrorrV   ÚopenÚdevnullÚO_WRONLYÚdup2Úfileno)Úcoder~   r?   r?   r@   Úconsole_mainÂ   s    
rƒ   c                   @  s   e Zd ZeeƒZdS )ÚcmdlineN)r8   r9   r:   Ústaticmethodrx   r?   r?   r?   r@   r„   Ô   s   r„   rK   )rE   ÚoptnamerG   c                 C  s"   t j | ¡rt|› d| › �ƒ‚| S )ztArgparse type validator for filename arguments.

    :path: Path of filename.
    :optname: Name of the option.
    z must be a filename, given: ©rV   rE   Úisdirr   ©rE   r†   r?   r?   r@   Úfilename_argØ   s    rŠ   c                 C  s"   t j | ¡st|› d| › �ƒ‚| S )zvArgparse type validator for directory arguments.

    :path: Path of directory.
    :optname: Name of the option.
    z must be a directory, given: r‡   r‰   r?   r?   r@   Údirectory_argã   s    r‹   )Úmarkrx   ÚrunnerZfixturesZ
helpconfigÚpythonÚterminalÚ	debuggingÚunittestÚcaptureÚskippingÚ
legacypathÚtmpdirÚmonkeypatchÚrecwarnÚpastebinÚ	assertionÚjunitxmlÚdoctestÚcacheproviderÚfreeze_supportÚ	setuponlyÚ	setupplanÚstepwiseÚwarningsÚloggingÚreportsÚpython_pathÚunraisableexceptionÚthreadexceptionÚfaulthandlerZpytesterZpytester_assertionszlist[str] | NoneÚConfigc                 C  sV   t ƒ }t|tj| pd|tj ¡ d�d�}| d k	r>|j| dd� tD ]}| |¡ qB|S )Nr?   ©rZ   r[   Údir©Úinvocation_paramsT©Úexclude_only)	ÚPytestPluginManagerr¨   ÚInvocationParamsÚpathlibÚPathÚcwdÚconsider_preparseÚdefault_pluginsÚimport_plugin)rZ   r[   Úpluginmanagerra   Úspecr?   r?   r@   Ú
get_config  s    ýþ	r¹   r¯   c                   C  s   t ƒ jS )zíObtain a new instance of the
    :py:class:`pytest.PytestPluginManager`, with default plugins
    already loaded.

    This function can be used by integration with other tools, like hooking
    into pytest to run tests into an IDE.
    )r¹   r·   r?   r?   r?   r@   Úget_plugin_manager3  s    rº   c                 C  sÌ   | d krt jdd … } n<t| tjƒr2t | ¡g} n"t| tƒsTd}t| | t	| ƒ¡ƒ‚t
| |ƒ}|j}zD|r”|D ]$}t|tƒrˆ| |¡ qn| |¡ qn|jj|| d�}|W S  tk
rÆ   | ¡  ‚ Y nX d S )Nr   zG`args` parameter expected to be a list of strings, got: {!r} (type: {}))r·   rZ   )rh   ÚargvÚ
isinstancerV   ÚPathLikeÚfspathÚlistÚ	TypeErrorÚformatrO   r¹   r·   rK   Úconsider_pluginargÚregisterrq   Úpytest_cmdline_parseÚBaseExceptionrp   )rZ   r[   rw   ra   r·   Úpluginr?   r?   r@   rf   >  s0    
ÿ

 ÿrf   rB   ©rE   rG   c                 C  s   |   ¡ r| jS | S dS )z<Get the directory of a path - itself if already a directory.N)Úis_fileÚparent)rE   r?   r?   r@   Ú_get_directory^  s    rÊ   r   útuple[str, ...]zdict[str, bool])ÚmethodÚ	hook_typeÚ	opt_namesrG   c           
      C  sÎ   t rt | ¡st‚dd„ t| dg ƒD ƒ}g }i }|D ]`}t| |tƒ}|tk	rj| |› d|› �¡ d||< q4||krŒ| |› d�¡ d||< q4d||< q4|rÊd |¡}tj	j
j|| j|d	�}	ttt| ƒ|	ƒ |S )
Nc                 S  s   h | ]
}|j ’qS r?   ©Úname)Ú.0Úmr?   r?   r@   Ú	<setcomp>n  s     z)_get_legacy_hook_marks.<locals>.<setcomp>Z
pytestmarkú=Tz=TrueFú, )rO   ÚfullnameÚ	hook_opts)r   ÚinspectÚ	isroutineÚAssertionErrorÚgetattrÚAttributeErrorÚappendÚjoinÚ_pytestÚ
deprecatedZHOOK_LEGACY_MARKINGrÁ   r:   r/   r   r   )
rÌ   rÍ   rÎ   Zknown_marksZ	must_warnÚoptsÚopt_nameZopt_attrr×   Úmessager?   r?   r@   Ú_get_legacy_hook_marksf  s.    



ýrä   c                
      s¶  e Zd ZdZddœ‡ fdd„Zdddd	œ‡ fd
d„Zdddœ‡ fdd„ZdUdddd	œ‡ fdd„Zddœdd„Zdddœdd„Z	dddœdd„Z
ddddd dd!ddd"œ	d#d$„Zddd%œd&d'„Zdd(dddd)œd*d+„Zdd(dddd,œd-d.„Zdd/d%œd0d1„Zddd2d3œd4d5„Zdd(ddd6d7œd8d9„Zd6ddd:œd;d<„Zd=d>œd?ddd@œdAdB„ZdddCœdDdE„Zd6dddFœdGdH„ZddœdIdJ„Zd6ddKœdLdM„ZdNddOœdPdQ„ZdVddddRœdSdT„Z‡  ZS )Wr¯   a;  A :py:class:`pluggy.PluginManager <pluggy.PluginManager>` with
    additional pytest-specific functionality:

    * Loading plugins from the command line, ``PYTEST_PLUGINS`` env variable and
      ``pytest_plugins`` global variables found in plugins being loaded.
    * ``conftest.py`` loading during start-up.
    rD   rL   c                   sÚ   dd l }tƒ  d¡ tƒ | _i | _d | _d| _tdƒt	ƒ| _	g | _
|  |j¡ |  | ¡ tj d¡rÄtj}t|ddƒ}z tt | ¡ ¡|jd|d	�}W n tk
rª   Y nX | jj |j¡ |  ¡  |j ¡ | _ d| _!d S )
Nr   r2   Fé   ZPYTEST_DEBUGÚencodingÚutf8r   )ÚmodeÚ	bufferingræ   )"Ú_pytest.assertionÚsuperrJ   ÚsetÚ_conftest_pluginsÚ_dirpath2confmodsÚ_confcutdirÚ_noconftestr   rÊ   Úskipped_pluginsZadd_hookspecsÚhookspecrÃ   rV   rc   rd   rh   ri   rÛ   r}   Údupr�   rè   rC   ÚtraceÚrootZ	setwriterÚwriteZenable_tracingr™   ZDummyRewriteHookÚrewrite_hookÚ_configured)rI   rß   Úerrræ   ©Ú	__class__r?   r@   rJ   �  s4    
ü
zPytestPluginManager.__init__Ú_PluggyPluginrK   zHookimplOpts | None)rÆ   rÐ   rG   c                   sX   |  d¡sdS |dkrdS tƒ  ||¡}|dk	r4|S t||ƒ}t |¡sLdS t|ddƒS )ú:meta private:Úpytest_NÚpytest_pluginsÚimpl)ZtryfirstÚtrylastZoptionalhookZhookwrapper)Ú
startswithrë   Úparse_hookimpl_optsrÛ   rØ   rÙ   rä   )rI   rÆ   rÐ   rá   rÌ   rú   r?   r@   r  Ã  s    


  ÿz'PytestPluginManager.parse_hookimpl_optszHookspecOpts | None©rÐ   rG   c                   s:   t ƒ  ||¡}|dkr6t||ƒ}| d¡r6t|ddƒ}|S )rý   Nrþ   r¸   )ZfirstresultZhistoric)rë   Úparse_hookspec_optsrÛ   r  rä   )rI   Zmodule_or_classrÐ   rá   rÌ   rú   r?   r@   r  Ý  s    

ýz'PytestPluginManager.parse_hookspec_optsNú
str | Nonec              	     sv   |t jjkr,t td | dd¡¡ƒ¡ d S tƒ  	||¡}|d k	rr| j
jjt||| d�d� t|tjƒrr|  |¡ |S )NzQ{} plugin has been merged into the core, please remove it from your requirements.Ú_ú-)rÆ   Úplugin_nameÚmanager©Úkwargs)rß   rà   ZDEPRECATED_EXTERNAL_PLUGINSr¡   Úwarnr.   rÁ   Úreplacerë   rÃ   rq   Zpytest_plugin_registeredÚcall_historicÚdictr¼   ÚtypesÚ
ModuleTypeÚconsider_module)rI   rÆ   rÐ   r	  rú   r?   r@   rÃ   ê  s*    
þÿÿýÿ
zPytestPluginManager.registerrÏ   c                 C  s   |   |¡}|S rH   )Ú
get_plugin)rI   rÐ   rÆ   r?   r?   r@   Ú	getplugin  s    
zPytestPluginManager.getpluginrR   c                 C  s   t |  |¡ƒS )z:Return whether a plugin with the given name is registered.)rR   r  )rI   rÐ   r?   r?   r@   Ú	hasplugin  s    zPytestPluginManager.haspluginr¨   )ra   rG   c                 C  s"   |  dd¡ |  dd¡ d| _dS )rý   Úmarkerszµtryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible. DEPRECATED, use @pytest.hookimpl(tryfirst=True) instead.z±trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible. DEPRECATED, use @pytest.hookimpl(trylast=True) instead.TN)Úaddinivalue_linerø   )rI   ra   r?   r?   r@   Úpytest_configure  s    þþz$PytestPluginManager.pytest_configurezSequence[str | pathlib.Path]rB   úpathlib.Path | NonezImportMode | str)	rZ   ÚpyargsÚ
noconftestÚrootpathÚ
confcutdirÚinvocation_dirÚ
importmodeÚconsider_namespace_packagesrG   c                C  sš   |rt || ƒnd| _|| _|| _d}	|D ]T}
t|
ƒ}| d¡}|dkrT|d|… }t || ƒ}t|ƒr*| j||||d� d}	q*|	s–| j||||d� dS )a`  Load initial conftest files given a preparsed "namespace".

        As conftest files may add their own command line options which have
        arguments ('--my-opt somepath') we might get some false positives.
        All builtin and 3rd party plugins will have been loaded, however, so
        common options will not confuse our logic here.
        NFú::éÿÿÿÿ©r!  T)r'   rï   rð   Ú_using_pyargsrK   Úfindr,   Ú_try_load_conftest)rI   rZ   r  r  r  r  r  r   r!  ZfoundanchorZinitial_pathrE   ÚiÚanchorr?   r?   r@   Ú_set_initial_conftests!  s4    ÿ
üüz*PytestPluginManager._set_initial_conftestsrÇ   c                 C  s   | j dkrdS || j jkS )z:Whether to consider the given path to load conftests from.NT)rï   Úparents)rI   rE   r?   r?   r@   Ú_is_in_confcutdirT  s    

z%PytestPluginManager._is_in_confcutdirzstr | ImportMode)r)  r   r  r!  rG   c                C  sH   | j ||||d� | ¡ rD| d¡D ]}| ¡ r$| j ||||d� q$d S )Nr$  ztest*)Ú_loadconftestmodulesÚis_dirÚglob)rI   r)  r   r  r!  Úxr?   r?   r@   r'  c  s    üüz&PytestPluginManager._try_load_conftest)rE   r   r  r!  rG   c          
      C  s€   | j r
d S |  |¡}|| jkr"d S g }t|f|j˜ƒD ]:}|  |¡r6|d }| ¡ r6| j||||d�}	| |	¡ q6|| j|< d S )Nzconftest.pyr$  )	rð   rÊ   rî   Úreversedr+  r,  rÈ   Ú_importconftestrÝ   )
rI   rE   r   r  r!  Ú	directoryZclistrÉ   ÚconftestpathÚmodr?   r?   r@   r-  |  s$    


üz(PytestPluginManager._loadconftestmoduleszSequence[types.ModuleType]c                 C  s   |   |¡}| j |d¡S )Nr?   )rÊ   rî   rd   )rI   rE   r3  r?   r?   r@   Ú_getconftestmodulesœ  s    
z'PytestPluginManager._getconftestmodulesztuple[types.ModuleType, Any]©rÐ   rE   rG   c              	   C  sR   |   |¡}t|ƒD ]2}z|t||ƒfW   S  tk
rB   Y qY qX qt|ƒ‚d S rH   )r6  r1  rÛ   rÜ   ÚKeyError)rI   rÐ   rE   Úmodulesr5  r?   r?   r@   Ú_rget_with_confmod   s    
z&PytestPluginManager._rget_with_confmodztypes.ModuleType)r4  r   r  r!  rG   c             
   C  sR  t |ƒ}|  |¡}|d k	r&ttj|ƒS t|ƒ}|d krZztj|j= W n t	k
rX   Y nX zt
||||d�}W n> tk
r¬ }	 z |	jd k	sŽt‚t||	d�|	‚W 5 d }	~	X Y nX |  ||¡ | j |¡ |j}
|
| jk�r0| j ¡ D ]L\}}|
|jksü||
krâ||k�r$td|›d|› d|j› d�ƒ‚| |¡ qâ|  d|›�¡ | j||d� |S )	N)rè   rõ   r!  )rF   z#While trying to load conftest path z, found that the module z is already loaded with path zE. This is not supposed to happen. Please report this issue to pytest.zloading conftestmodule )Úregistration_name)rK   r  r   r  r  r+   rh   r9  Ústemr8  r)   rC   Ú__traceback__rÚ   rA   Ú_check_non_top_pytest_pluginsrí   ÚaddrÉ   rî   Úitemsr+  Ú__file__rÝ   rô   Úconsider_conftest)rI   r4  r   r  r!  Zconftestpath_plugin_nameÚexistingÚpkgpathr5  rs   ÚdirpathrE   Zmodsr?   r?   r@   r2  ­  sD    
ü
 
ÿz#PytestPluginManager._importconftest)r5  r4  rG   c                 C  s4   t |dƒr0| jr0| js0d}t| || j¡dd� d S )Nrÿ   af  Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:
It affects the entire test suite instead of just below the conftest as expected.
  {}
Please move it to a top level conftest file at the rootdir:
  {}
For more information, visit:
  https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-filesF)Zpytrace)Úhasattrrø   r%  r%   rÁ   rï   )rI   r5  r4  rw   r?   r?   r@   r>  â  s    ÿþýÿ	z1PytestPluginManager._check_non_top_pytest_pluginsFr­   úSequence[str])rZ   r®   rG   c                C  s¦   d}t |ƒ}||k r¢|| }|d7 }t|tƒr|dkrdz|| }W n tk
rX   Y dS X |d7 }n| d¡r|dd… }nq| ¡ }|r–| d¡s–q|  |¡ qdS )rý   r   r   z-pNr4   úno:)Úlenr¼   rK   Ú
IndexErrorr  ÚstriprÂ   )rI   rZ   r®   r(  ÚnÚoptZpargr?   r?   r@   r´   ü  s&    


z%PytestPluginManager.consider_preparse)ÚargrG   c                 C  s¦   |  d¡rn|dd… }|tkr.td|› d�ƒ‚|dkrJ|  d¡ |  d¡ |  |¡ |  d	¡s¢|  d	| ¡ n4|}|  |¡ |  d	¡s”|  d	| ¡ | j|d
d� dS )rý   rH  r5   Nzplugin z cannot be disabledrœ   r    Zpytest_stepwiserþ   T)Úconsider_entry_points)r  Úessential_pluginsr   Zset_blockedZunblockr¶   )rI   rN  rÐ   r?   r?   r@   rÂ     s    






z&PytestPluginManager.consider_pluginarg)Úconftestmoduler;  rG   c                 C  s   | j ||d� dS )rý   rÏ   N)rÃ   )rI   rQ  r;  r?   r?   r@   rB  ,  s    z%PytestPluginManager.consider_conftestc                 C  s   |   tj d¡¡ dS )rý   ZPYTEST_PLUGINSN)Ú_import_plugin_specsrV   rc   rd   rP   r?   r?   r@   Úconsider_env2  s    z PytestPluginManager.consider_env)r5  rG   c                 C  s   |   t|dg ƒ¡ dS )rý   rÿ   N)rR  rÛ   )rI   r5  r?   r?   r@   r  6  s    z#PytestPluginManager.consider_moduleú-None | types.ModuleType | str | Sequence[str])r¸   rG   c                 C  s    t |ƒ}|D ]}|  |¡ qd S rH   )Ú_get_plugin_specs_as_listr¶   )rI   r¸   r[   Zimport_specr?   r?   r@   rR  :  s    z(PytestPluginManager._import_plugin_specs)ÚmodnamerO  rG   c              
   C  s  t |tƒstd|›�ƒ‚|  |¡s0|  |¡dk	r4dS |tkrDd| n|}| j |¡ |rn| jd|d�}|rndS zt	|ƒ W n| t
k
rÀ } z(t
d|› d|jd › �ƒ |j¡|‚W 5 d}~X Y nN tk
rö } z| j ||jpàd	f¡ W 5 d}~X Y nX tj| }|  ||¡ dS )
z™Import a plugin with ``modname``.

        If ``consider_entry_points`` is True, entry point names are also
        considered to find a plugin.
        z"module name as text required, got Nz_pytest.Úpytest11rÏ   zError importing plugin "z": r   Ú )r¼   rK   rÚ   Ú
is_blockedr  Úbuiltin_pluginsr÷   Úmark_rewriteÚload_setuptools_entrypointsÚ
__import__ÚImportErrorrZ   Úwith_tracebackr=  r&   rñ   rÝ   rw   rh   r9  rÃ   )rI   rV  rO  Z
importspecZloadedrs   r5  r?   r?   r@   r¶   A  s8    
 ÿþÿþþ(
z!PytestPluginManager.import_plugin)N)F)r8   r9   r:   r;   rJ   r  r  rÃ   r  r  r  r*  r,  r'  r-  r6  r:  r2  r>  r´   rÂ   rB  rS  r  rR  r¶   Ú__classcell__r?   r?   rú   r@   r¯   †  s0   33 5ÿrT  ú	list[str])ÚspecsrG   c                 C  s`   | dkrg S t | tjƒrg S t | tƒr8| r4|  d¡S g S t | tjjƒrNt| ƒS t	d| ›�ƒ‚dS )z:Parse a plugins specification into a list of plugin names.Nú,zWPlugins may be specified as a sequence or a ','-separated string of plugin names. Got: )
r¼   r  r  rK   rU   ÚcollectionsÚabcr   r¿   r   )rb  r?   r?   r@   rU  g  s    
ÿrU  c                   @  s   e Zd Zdd„ ZdS )ÚNotsetc                 C  s   dS )Nz<NOTSET>r?   rP   r?   r?   r@   Ú__repr__}  s    zNotset.__repr__N)r8   r9   r:   rg  r?   r?   r?   r@   rf  |  s   rf  úIterable[str]zIterator[str])Úpackage_filesrG   c                 c  sÞ   t | ƒ} d}| D ]z}d|ko$| d¡}| d¡dko<| d¡}|rptj |¡\}}|dkrŠ| d¡sŠd}|V  q|rtj |¡}d}|V  q|sÚg }| D ].}| d¡}	d 	|	dd	… ¡}
|
r˜| 
|
¡ q˜|rÚt|ƒE d	H  d	S )
aM  Given an iterable of file names in a source distribution, return the "names" that should
    be marked for assertion rewrite.

    For example the package "pytest_mock/__init__.py" should be added as "pytest_mock" in
    the assertion rewrite mechanism.

    This function has to deal with dist-info based distributions and egg based distributions
    (which are still very much in use for "editable" installs).

    Here are the file names as seen in a dist-info based distribution:

        pytest_mock/__init__.py
        pytest_mock/_version.py
        pytest_mock/plugin.py
        pytest_mock.egg-info/PKG-INFO

    Here are the file names as seen in an egg based distribution:

        src/pytest_mock/__init__.py
        src/pytest_mock/_version.py
        src/pytest_mock/plugin.py
        src/pytest_mock.egg-info/PKG-INFO
        LICENSE
        setup.py

    We have to take in account those two distribution flavors in order to determine which
    names should be considered for assertion rewriting.

    More information:
        https://github.com/pytest-dev/pytest-mock/issues/167
    Fú/z.pyr   z__init__.pyÚsetupZ__editable__TN)r¿   ÚendswithÚcountrV   rE   Úsplitextr  ÚdirnamerU   rÞ   rÝ   Ú_iter_rewritable_modules)ri  Z	seen_someÚfnZis_simple_moduleÚ
is_packageÚmodule_namer  Úpackage_nameZnew_package_filesÚpartsZnew_fnr?   r?   r@   rp  „  s.     
rp  c                   @  s>  e Zd ZU dZeejdd�G dd„ dƒƒƒZG dd„ dej	ƒZ
ded	< d
dœddddœdd„Zeddœdd„ƒZeddœdd„ƒZdddœdd„Zddœdd„Zddœdd „Zd!dœd"d#„Zdd$d d%œd&d'„Zd•d(d)dd*œd+d,„Zd-d-d.œd/d0„Zed dœd1d2„ƒZd3dd4œd5d6„Zedd7�d dd8œd9d:„ƒZd;dd<œd=d>„Zd;dd<œd?d@„ZddœdAdB„Zd$d-d$dCœdDdE„Zd$dFd$dddFdGdHœdIdJ„Z d–d$dFddKœdLdM„Z!eddN�dOdœdPdQ„ƒZ"ddœdRdS„Z#ddœdTdU„Z$ddœdVdW„Z%d-ddXœdYdZ„Z&d$dœd[d\„Z'd—d$dFddKœd]d^„Z(d_d`ddaœdbdc„Z)d-d-dddœdedf„Z*d-dgœdhdi„Z+d-d-djdkœdldm„Z,d-dgœdndo„Z-d-ddpdqœdrds„Z.d-dtduœdvdw„Z/e0dxfd-dFdyœdzd{„Z1d˜d-dgœd|d}„Z2d™d-dgœd~d„Z3d€Z4d�ed‚< dƒZ5d�ed„< d…Z6d�ed†< dšdtd`d‡œdˆd‰„Z7e8d-d-d‡œdŠd‹„ƒZ9e8dŒd-d-dd�œdŽd�„ƒZ:d-dd�œd‘d’„Z;ddœd“d”„Z<d
S )›r¨   a  Access to configuration values, pluginmanager and plugin hooks.

    :param PytestPluginManager pluginmanager:
        A pytest PluginManager.

    :param InvocationParams invocation_params:
        Object containing parameters regarding the :func:`pytest.main`
        invocation.
    T)Úfrozenc                   @  s>   e Zd ZU dZded< ded< ded< dddd	d
œdd„ZdS )zConfig.InvocationParamsaš  Holds parameters passed during :func:`pytest.main`.

        The object attributes are read-only.

        .. versionadded:: 5.1

        .. note::

            Note that the environment variable ``PYTEST_ADDOPTS`` and the ``addopts``
            ini option are handled by pytest, not being included in the ``args`` attribute.

            Plugins accessing ``InvocationParams`` must be aware of that.
        rË   rZ   rY   r[   rB   rª   rh  rD   )rZ   r[   rª   rG   c                C  s2   t  | dt|ƒ¡ t  | d|¡ t  | d|¡ d S )NrZ   r[   rª   )ÚobjectÚ__setattr__Útuple)rI   rZ   r[   rª   r?   r?   r@   rJ   é  s    z Config.InvocationParams.__init__N)r8   r9   r:   r;   Ú__annotations__rJ   r?   r?   r?   r@   r°   Ñ  s
   
r°   c                   @  s,   e Zd ZdZe ¡ Ze ¡ ZeZe ¡ Z	dS )zConfig.ArgsSourcezSIndicates the source of the test arguments.

        .. versionadded:: 7.2
        N)
r8   r9   r:   r;   ÚenumÚautoÚARGSÚINVOCATION_DIRZINCOVATION_DIRÚ	TESTPATHSr?   r?   r?   r@   Ú
ArgsSourceô  s
   r€  r0   ÚcacheNr«   r¯   zInvocationParams | NonerD   )r·   r¬   rG   c                C  sü   ddl m} ddl m} |d kr6| jdd tj ¡ d�}t ¡ | _	|| _
|}|d|› d|› d�| jd	d
�| _|| _tƒ | _| j| _| jjj d¡| _t| jjƒ| _i | _d| _i | _g | _| j | d¡ d| _| jjjt| j| jd�d� tj j!| _"g | _#d S )Nr   )ÚFILE_OR_DIRr#   r?   r©   z%(prog)s [options] [z] [z] [...]T)ÚusageZ
processoptZ	_ispytestra   ZpytestconfigF)Úparserr·   r  )$Z
argparsingr‚  r$   r°   r±   r²   r³   ÚargparseÚ	NamespaceÚoptionr¬   Ú_processoptÚ_parserr·   r-   ÚstashÚ_storerô   rõ   rd   r   rq   Ú	_inicacheÚ_override_iniÚ	_opt2destÚ_cleanuprÃ   rø   Zpytest_addoptionr  r  r¨   r€  r}  Úargs_sourcerZ   )rI   r·   r¬   r‚  r$   Z_ar?   r?   r@   rJ     s@      ÿ
ýÿ
zConfig.__init__rB   rL   c                 C  s   | j S )znThe path to the :ref:`rootdir <rootdir>`.

        :type: pathlib.Path

        .. versionadded:: 6.1
        )Ú	_rootpathrP   r?   r?   r@   r  B  s    zConfig.rootpathr  c                 C  s   | j S )zXThe path to the :ref:`configfile <configfiles>`.

        .. versionadded:: 6.1
        )Ú_inipathrP   r?   r?   r@   ÚinipathL  s    zConfig.inipathzCallable[[], None])ÚfuncrG   c                 C  s   | j  |¡ dS )zxAdd a function to be called when the config object gets out of
        use (usually coinciding with pytest_unconfigure).N)r�  rÝ   )rI   r”  r?   r?   r@   Úadd_cleanupT  s    zConfig.add_cleanupc              	   C  sH   | j r
t‚d| _ t ¡ �& t d¡ | jjjt| d�d� W 5 Q R X d S )NTÚdefaultr`   r  )	rø   rÚ   r¡   Úcatch_warningsÚsimplefilterrq   r  r  r  rP   r?   r?   r@   Ú_do_configureY  s
    


zConfig._do_configurec                 C  s@   | j r$d| _ | jj| d� g | jj_| jr<| j ¡ }|ƒ  q$d S )NFr`   )rø   rq   Zpytest_unconfigurer  Z_call_historyr�  re   )rI   Zfinr?   r?   r@   rp   `  s    

zConfig._ensure_unconfigurer!   c                 C  s   | j  d¡}|d k	st‚|jS )NÚterminalreporter)r·   r  rÚ   Z_tw)rI   rš  r?   r?   r@   Úget_terminal_writeri  s
    ÿzConfig.get_terminal_writerra  )r·   rZ   rG   c                 C  sŽ   z|   |¡ W nz tk
rˆ   t| jddƒs4d|krJddlm} || ƒ n8t| jddƒshd|kshd|kr‚| j ¡  ¡  t	j
 d	¡ ‚ Y nX | S )
NÚversionFz	--versionr   )ÚshowversionÚhelpz--helpz-hz8
NOTE: displaying only minimal help due to UsageError.

)Úparser   rÛ   r‡  Z_pytest.helpconfigr�  r‰  Z
_getparserÚ
print_helprh   rz   rö   )rI   r·   rZ   r�  r?   r?   r@   rÄ   p  s$    
ÿÿÿÿzConfig.pytest_cmdline_parsezExceptionInfo[BaseException]zargparse.Namespace | None)Úexcinfor‡  rG   c                 C  s€   |rt |ddƒrd}nd}|jdt |ddƒ|d�}| jj||d�}t|ƒs|t|ƒ d	¡D ]"}tj 	d
|› d	�¡ tj 
¡  qXd S )NZ	fulltraceFÚlongÚnativeTÚ
showlocals)Zfuncargsr¤  r^   )Úexcreprr¡  rb   zINTERNALERROR> )rÛ   rm   rq   Zpytest_internalerrorÚanyrK   rU   rh   ri   rö   r{   )rI   r¡  r‡  r^   r¥  Úresrj   r?   r?   r@   Únotify_exception‰  s     
 ÿzConfig.notify_exceptionrK   )ÚnodeidrG   c                 C  sH   | j j| jkrD| d¡^}}| j| }t| j j|ƒ}d |f|•¡}|S )Nr"  )r¬   rª   r  rU   r(   rÞ   )rI   r©  Zbase_path_partZnodeid_partÚfullpathÚrelative_pathr?   r?   r@   Úcwd_relative_nodeid›  s    
zConfig.cwd_relative_nodeidc                 C  sB   t |ƒ}|jj |¡ |j|dd� |jjD ]}|j |¡ q,|S )z$Constructor usable for subprocesses.F©Úaddopts)r¹   r‡  Ú__dict__ÚupdaterŸ  r[   r·   rÂ   )ÚclsÚoption_dictrZ   ra   r0  r?   r?   r@   Úfromdictargs¦  s    zConfig.fromdictargsr"   )rM  rG   c                 C  sL   |j |j D ]}|j| j|< qt|dƒrHt| j|jƒsHt| j|j|jƒ d S )Nr–  )Ú_short_optsÚ
_long_optsÚdestrŽ  rF  r‡  Úsetattrr–  )rI   rM  rÐ   r?   r?   r@   rˆ  °  s
    
zConfig._processopt)r  )Úearly_configrG   c                 C  sj   |j |jj|jj| d¡|jj|jdd�\}}| jj	||jj|jj
|j|jj|jj|jj| d¡d� d S )NÚ	testpathsF©rZ   r  r¹  r  r  r  r!  )rZ   r  r  r  r  r  r   r!  )Ú_decide_argsÚknown_args_namespaceÚfile_or_dirr  Úgetinir¬   rª   r  r·   r*  r  r  r   )rI   r¸  rZ   r�  r?   r?   r@   Úpytest_load_initial_conftests¸  s(    ú
ÿøz$Config.pytest_load_initial_conftestsrG  )rZ   rG   c                 C  s¼   | j j|t | j¡d�\}}t|j|j| |jp2d | jj	d�\}}}|| _
|| _|| _t| jƒ| j jd< t| jƒ| j jd< | j  ddd¡ | j  dd	¡ | j jd
ddg d� |jp´d| _d S )N©Ú	namespace)ÚinifilerZ   Zrootdir_cmd_argr  ÚrootdirrÂ  r®  zExtra command line optionsrZ   Ú
minversionz!Minimally required pytest versionÚrequired_pluginsz.Plugins that must be present for pytest to run)rO   r–  r?   )r‰  Úparse_known_and_unknown_argsÚcopyr‡  r   Zinifilenamer½  rÃ  r¬   rª   r‘  r’  ÚinicfgrK   r  Z
extra_infor“  ÚaddiniZoverride_inir�  )rI   rZ   ÚnsÚunknown_argsr  r“  rÈ  r?   r?   r@   Ú_initiniÓ  s0     
ÿ
üüzConfig._initinic                 C  sn   | j  |¡\}}t|ddƒ}|dkr`ddl}z|j | ¡}W n tk
rT   d}Y nX |  |¡ |  |¡ dS )zïInstall the PEP 302 import hook if using assertion rewriting.

        Needs to parse the --assert=<mode> option from the commandline
        and find all the installed plugins to mark them for rewriting
        by the importhook.
        Z
assertmodeÚplainZrewriter   N)	r‰  rÆ  rÛ   rê   r™   Zinstall_importhookÚSystemErrorÚ_mark_plugins_for_rewriteÚ_warn_about_missing_assertion)rI   rZ   rÊ  rË  rè   rß   rq   r?   r?   r@   Ú_consider_importhookì  s    

zConfig._consider_importhookc                 C  sH   || j _tj d¡rdS dd„ tj ¡ D ƒ}t|ƒD ]}| 	|¡ q4dS )z‹Given an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins.ÚPYTEST_DISABLE_PLUGIN_AUTOLOADNc                 s  s:   | ]2}t d d„ |jD ƒƒr|jp"g D ]}t|ƒV  q$qdS )c                 s  s   | ]}|j d kV  qdS )rW  N)Úgroup)rÑ   Úepr?   r?   r@   Ú	<genexpr>  s     z=Config._mark_plugins_for_rewrite.<locals>.<genexpr>.<genexpr>N)r¦  Úentry_pointsÚfilesrK   )rÑ   ÚdistÚfiler?   r?   r@   rÕ    s
    ýz3Config._mark_plugins_for_rewrite.<locals>.<genexpr>)
r·   r÷   rV   rc   rd   rT   ÚmetadataÚdistributionsrp  r[  )rI   rq   ri  rÐ   r?   r?   r@   rÏ     s    þz Config._mark_plugins_for_rewrite)rZ   ÚviarG   c                 C  s2   || j _z| j j|t | j¡d� W 5 | j `X |S )zValidate known args.rÀ  )r‰  Z_config_source_hintrÆ  rÇ  r‡  )rI   rZ   rÜ  r?   r?   r@   Ú_validate_args  s     
ÿ
zConfig._validate_argsrR   ztuple[list[str], ArgsSource])rZ   r  r¹  r  r  r  rG   c                C  s˜   |rt jj}|}n~||krvt jj}|r,|}qzg }|D ]}	| ttj|	dd�ƒ¡ q4|rz|sz|rzd}
| jt	|
ƒdd� ng }|s�t jj
}t|ƒg}||fS )zÑDecide the args (initial paths/nodeids) to use given the relevant inputs.

        :param warn: Whether can issue warnings.

        :returns: The args and the args source. Guaranteed to be non-empty.
        T)Ú	recursivez˜No files were found in testpaths; consider removing or adjusting your testpaths configuration. Searching recursively from the current directory instead.r5   ©Ú
stacklevel)r¨   r€  r}  r  ÚextendÚsortedr/  ÚiglobÚissue_config_time_warningr.   r~  rK   )rI   rZ   r  r¹  r  r  r  ÚsourceÚresultrE   Úwarning_textr?   r?   r@   r»  !  s.    ÿ ÿ
zConfig._decide_args)rZ   r®  rG   c              
   C  sš  |r8t j dd¡}t|ƒr8|  t |¡d¡| |d d …< |  |¡ |rd|  |  d¡d¡| |d d …< | j	j
|t | j¡d�| _|  ¡  |  |¡ | jj|dd� t j d	¡s¸| j d
¡ | j ¡  | j	j
|t | j¡d�| _|  ¡  |  ¡  | jjd k�r&| jd k	�rt| jjƒ}n
t| jƒ}|| j_z| jj| || j	d� W nV tk
�r” } z6| jj�sf| jj�r‚| j t!d|j"› �ƒdd� n‚ W 5 d }~X Y nX d S )NZPYTEST_ADDOPTSrX  zvia PYTEST_ADDOPTSr®  zvia addopts configrÀ  Fr­   rÒ  rW  )r¸  rZ   r„  z"could not load initial conftests: r4   rß  )#rV   rc   rd   rI  rÝ  ÚshlexrU   rÌ  r¾  r‰  Úparse_known_argsrÇ  r‡  r¼  Ú_checkversionrÑ  r·   r´   r\  rS  Ú_validate_pluginsÚ_warn_about_skipped_pluginsr  r“  rK   rÉ   r  rq   r¿  rA   rž  rœ  rä  r.   rE   )rI   rZ   r®  Zenv_addoptsr  rs   r?   r?   r@   Ú	_preparseN  sZ    ÿÿ

ÿ
 
ÿ

 
ÿ
  ÿ
þzConfig._preparse)ÚwrapperzGenerator[None, object, object]c                 c  s   z
d V W ¢S |   ¡  X d S rH   )Ú_validate_config_optionsrP   r?   r?   r@   Úpytest_collection„  s    
zConfig.pytest_collectionc                 C  sx   dd l }| j dd ¡}|rtddlm} t|tƒsB| | j› d�¡‚||ƒ||j	ƒkrt| | j› d|› d|j	› d�¡‚d S )Nr   rÄ  ©ÚVersionz%: 'minversion' must be a single valuez: 'minversion' requires pytest-z, actual pytest-ú')
r2   rÈ  rd   Úpackaging.versionrò  r¼   rK   r   r“  r   )rI   r2   Zminverrò  r?   r?   r@   rê  �  s    

ÿÿzConfig._checkversionc                 C  s(   t |  ¡ ƒD ]}|  d|› d�¡ qd S )NzUnknown config option: rb   )râ  Ú_get_unknown_ini_keysÚ_warn_or_fail_if_strict)rI   Úkeyr?   r?   r@   rï  Ÿ  s    zConfig._validate_config_optionsc           
   	   C  sæ   t |  d¡ƒ}|sd S ddlm} ddlm} ddlm} | j ¡ }dd„ |D ƒ}g }|D ]n}z||ƒ}	W n" |k
rŒ   | 	|¡ Y qZY nX |	j
|kr¤| 	|¡ qZ|	jj|||	j
 ƒdd	�sZ| 	|¡ qZ|râtd
 d |¡¡ƒ‚d S )NrÅ  r   )ÚInvalidRequirement)ÚRequirementrñ  c                 S  s   i | ]\}}|j |j“qS r?   )Úproject_namerœ  )rÑ   r  rØ  r?   r?   r@   Ú
<dictcomp>®  s      z,Config._validate_plugins.<locals>.<dictcomp>T)ÚprereleaseszMissing required plugins: {}rÕ   )râ  r¾  Zpackaging.requirementsrø  rù  rô  rò  r·   Zlist_plugin_distinforÝ   rÐ   Ú	specifierÚcontainsr   rÁ   rÞ   )
rI   rÅ  rø  rù  rò  Zplugin_infoZplugin_dist_infoZmissing_pluginsZrequired_pluginÚreqr?   r?   r@   rë  £  s4    



 ÿÿzConfig._validate_plugins)rã   rG   c                 C  s&   | j jrt|ƒ‚| jt|ƒdd� d S )Nr5   rß  )r¼  Zstrict_configr   rä  r.   )rI   rã   r?   r?   r@   rö  Ä  s    zConfig._warn_or_fail_if_strictc                   s   | j j‰ ‡ fdd„| jD ƒS )Nc                   s   g | ]}|ˆ kr|‘qS r?   r?   )rÑ   rÐ   ©Zparser_inicfgr?   r@   Ú
<listcomp>Ì  s      z0Config._get_unknown_ini_keys.<locals>.<listcomp>)r‰  Ú_inidictrÈ  rP   r?   r   r@   rõ  Ê  s    zConfig._get_unknown_ini_keysc                 C  s¢   | j g kstdƒ‚| jjjt| jd�d� | j||d� d| j_	zH| jj
|| j| jd�}| j|| jj|  d¡| jj| jdd�\| _ | _W n tk
rœ   Y nX d S )	Nz:can only parse cmdline args at most once per Config object)r·   r  r­  TrÀ  r¹  rº  )rZ   rÚ   rq   Zpytest_addhooksr  r  r·   rí  r‰  Zafter_preparseZparse_setoptionr‡  r»  r¼  r  r¾  r¬   rª   r  r�  r   )rI   rZ   r®  r?   r?   r@   rŸ  Î  s2    ÿþ
ÿ  ÿúzConfig.parseÚWarningry   )Úwarningrà  rG   c              	   C  s°   | j  d¡rdS | jjpg }|  d¡}tjdd��.}t dt|ƒ¡ t	||ƒ tj
||d� W 5 Q R X |r¬t |d ¡}|jj|j|jjf}| jjjt|d	 d
d|d�d� dS )a  Issue and handle a warning during the "configure" stage.

        During ``pytest_configure`` we can't capture warnings using the ``catch_warnings_for_item``
        function because it is not possible to have hook wrappers around ``pytest_configure``.

        This function is mainly intended for plugins that need to issue warnings during
        ``pytest_configure`` (or similar stages).

        :param warning: The warning instance.
        :param stacklevel: stacklevel forwarded to warnings.warn.
        r¡   NÚfilterwarningsT)ÚrecordÚalwaysrß  r   r   ra   rX  )Zwarning_messageÚwhenr©  Úlocationr  )r·   rY  r¼  Zpythonwarningsr¾  r¡   r—  r˜  rO   Úapply_warning_filtersr  rh   Ú	_getframeÚf_codeÚco_filenameÚf_linenoÚco_namerq   Zpytest_warning_recordedr  r  )rI   r  rà  Úcmdline_filtersÚconfig_filtersÚrecordsÚframer	  r?   r?   r@   rä  ç  s&    

üÿz Config.issue_config_time_warning)rÐ   rj   rG   c                 C  s&   |   |¡}t|tƒst‚| |¡ dS )z©Add a line to an ini-file option. The option must have been
        declared but might not yet be set in which case the line becomes
        the first line in its value.N)r¾  r¼   r¿   rÚ   rÝ   )rI   rÐ   rj   r0  r?   r?   r@   r  
  s    
zConfig.addinivalue_linerÏ   c                 C  s>   z| j | W S  tk
r8   |  |¡ | j |< }| Y S X dS )a8  Return configuration value from an :ref:`ini file <configfiles>`.

        If a configuration value is not defined in an
        :ref:`ini file <configfiles>`, then the ``default`` value provided while
        registering the configuration through
        :func:`parser.addini <pytest.Parser.addini>` will be returned.
        Please note that you can even provide ``None`` as a valid
        default value.

        If ``default`` is not provided while registering using
        :func:`parser.addini <pytest.Parser.addini>`, then a default value
        based on the ``type`` parameter passed to
        :func:`parser.addini <pytest.Parser.addini>` will be returned.
        The default values based on ``type`` are:
        ``paths``, ``pathlist``, ``args`` and ``linelist`` : empty list ``[]``
        ``bool`` : ``False``
        ``string`` : empty string ``""``

        If neither the ``default`` nor the ``type`` parameter is passed
        while registering the configuration through
        :func:`parser.addini <pytest.Parser.addini>`, then the configuration
        is treated as a string and a default empty string '' is returned.

        If the specified name hasn't been registered through a prior
        :func:`parser.addini <pytest.Parser.addini>` call (usually from a
        plugin), a ValueError is raised.
        N)rŒ  r8  Ú_getini)rI   rÐ   Úvalr?   r?   r@   r¾    s
    zConfig.getinizstr | list[str])rÐ   rO   Úvaluec                 C  s   d|› �}t ||ƒ‚d S )Nzunknown configuration type: )rr   )rI   rÐ   rO   r  rw   r?   r?   r@   Ú_getini_unknown_type6  s    
zConfig._getini_unknown_typec           	   
     sx  z| j j| \}}}W n2 tk
rH } ztd|›�ƒ|‚W 5 d }~X Y nX |  |¡}|d kr†z| j| }W qŠ tk
r‚   | Y S X n|}|dkrÖ| jd k	r¤| jjn| jj	‰ t
|tƒrÀt |¡n|}‡ fdd„|D ƒS |dkröt
|tƒròt |¡S |S |dk�r0t
|tƒ�r*dd„ tdd	„ | d
¡ƒD ƒS |S nD|dk�rJtt|ƒ ¡ ƒS |dk�rX|S |d k�rf|S |  |||¡S d S )Nzunknown configuration value: Úpathsc                   s   g | ]}ˆ | ‘qS r?   r?   )rÑ   r0  ©Zdpr?   r@   r  ]  s     z"Config._getini.<locals>.<listcomp>rZ   Zlinelistc                 S  s   g | ]}|r|‘qS r?   r?   )rÑ   Útr?   r?   r@   r  b  s      c                 S  s   |   ¡ S rH   ©rK  )r0  r?   r?   r@   Ú<lambda>b  ó    z Config._getini.<locals>.<lambda>rb   rR   Ústring)r‰  r  r8  rr   Ú_get_override_ini_valuerÈ  r“  rÉ   r¬   rª   r¼   rK   rè  rU   ÚmapÚ
_strtoboolrK  r  )	rI   rÐ   ÚdescriptionrO   r–  rs   Zoverride_valuer  Zinput_valuesr?   r  r@   r  :  s>    "
ÿ
ý



zConfig._getinizlist[pathlib.Path] | Noner7  c                 C  s˜   z| j  ||¡\}}W n tk
r,   Y d S X |jd k	s<t‚t |j¡j}g }|D ]@}t|t	j
ƒrnt |¡}n| dt	j¡}t|| ƒ}| |¡ qR|S )Nrj  )r·   r:  r8  rA  rÚ   r±   r²   rÉ   r¼   rV   r½   r  rW   r'   rÝ   )rI   rÐ   rE   r5  ZrelrootsÚmodpathÚvaluesZrelrootr?   r?   r@   Ú_getconftest_pathlistn  s    zConfig._getconftest_pathlistr  r  c                 C  sj   d }| j D ]Z}z| dd¡\}}W n4 tk
rV } ztd|›d�ƒ|‚W 5 d }~X Y q
X ||kr
|}q
|S )NrÔ   r   z3-o/--override-ini expects option=value style (got: z).)r�  rU   rr   r   )rI   rÐ   r  Z
ini_configr÷  Zuser_ini_valuers   r?   r?   r@   r  �  s    

ÿþzConfig._get_override_ini_valueF)rÐ   Úskipc              
   C  sž   | j  ||¡}z&t| j|ƒ}|dkr0|r0t|ƒ‚|W S  tk
r˜ } zF|tk	rZ| W Y ¢4S |rxddl}| d|›d�¡ td|›�ƒ|‚W 5 d}~X Y nX dS )as  Return command line option value.

        :param name: Name of the option. You may also specify
            the literal ``--OPT`` option instead of the "dest" option name.
        :param default: Fallback value if no option of that name is **declared** via :hook:`pytest_addoption`.
            Note this parameter will be ignored when the option is **declared** even if the option's value is ``None``.
        :param skip: If ``True``, raise :func:`pytest.skip` if option is undeclared or has a ``None`` value.
            Note that even if ``True``, if a default was specified it will be returned instead of a skip.
        Nr   zno z option foundzno option named )	rŽ  rd   rÛ   r‡  rÜ   Únotsetr2   r&  rr   )rI   rÐ   r–  r&  r  rs   r2   r?   r?   r@   Ú	getoption’  s    
zConfig.getoptionc                 C  s
   |   |¡S )z$Deprecated, use getoption() instead.©r(  ©rI   rÐ   rE   r?   r?   r@   Úgetvalue«  s    zConfig.getvaluec                 C  s   | j |dd�S )z-Deprecated, use getoption(skip=True) instead.T)r&  r)  r*  r?   r?   r@   Úgetvalueorskip¯  s    zConfig.getvalueorskipZ
assertionsr	   ÚVERBOSITY_ASSERTIONSZ
test_casesÚVERBOSITY_TEST_CASESr|  Ú_VERBOSITY_INI_DEFAULT)Úverbosity_typerG   c                 C  sb   | j ddd�}t|tƒst‚|dkr(|S t |¡}|| jjkrB|S |  |¡}|tj	krZ|S t|ƒS )a5  Retrieve the verbosity level for a fine-grained verbosity type.

        :param verbosity_type: Verbosity type to get level for. If a level is
            configured for the given type, that value will be returned. If the
            given type is not a known verbosity type, the global verbosity
            level will be returned. If the given type is None (default), the
            global verbosity level will be returned.

        To configure a level for a fine-grained verbosity type, the
        configuration file should have a setting for the configuration name
        and a numeric value for the verbosity level. A special value of "auto"
        can be used to explicitly use the global verbosity level.

        Example:

        .. code-block:: ini

            # content of pytest.ini
            [pytest]
            verbosity_assertions = 2

        .. code-block:: console

            pytest -v

        .. code-block:: python

            print(config.get_verbosity())  # 1
            print(config.get_verbosity(Config.VERBOSITY_ASSERTIONS))  # 2
        Úverboser   )r–  N)
r(  r¼   ry   rÚ   r¨   Ú_verbosity_ini_namer‰  r  r¾  r/  )rI   r0  Zglobal_levelZini_nameÚlevelr?   r?   r@   Úget_verbosity¹  s    


zConfig.get_verbosityc                 C  s
   d| › �S )NZ
verbosity_r?   )r0  r?   r?   r@   r2  ç  s    zConfig._verbosity_ini_namer$   )r„  r0  rž  rG   c                 C  s   | j t |¡|dtjd� dS )a£  Add a output verbosity configuration option for the given output type.

        :param parser: Parser for command line arguments and ini-file values.
        :param verbosity_type: Fine-grained verbosity category.
        :param help: Description of the output this type controls.

        The value should be retrieved via a call to
        :py:func:`config.get_verbosity(type) <pytest.Config.get_verbosity>`.
        r  )rž  rO   r–  N)rÉ  r¨   r2  r/  )r„  r0  rž  r?   r?   r@   Ú_add_verbosity_inië  s    üzConfig._add_verbosity_ini)rè   rG   c                 C  s.   t ƒ s*|dkrd}nd}| jt|ƒdd� d S )NrÍ  zRASSERTIONS ARE NOT EXECUTED and FAILING TESTS WILL PASS.  Are you using python -O?z¥assertions not in test modules or plugins will be ignored because assert statements are not executed by the underlying Python interpreter (are you using python -O?)
r5   rß  )Ú_assertion_supportedrä  r.   )rI   rè   rç  r?   r?   r@   rÐ  ý  s    ÿÿþz$Config._warn_about_missing_assertionc                 C  s4   | j jD ]&\}}| jtd|›d|› �ƒdd� qd S )Nzskipped plugin rM   r4   rß  )r·   rñ   rä  r.   )rI   rs  rw   r?   r?   r@   rì    s
    þz"Config._warn_about_skipped_plugins)N)T)T)N)N)N)=r8   r9   r:   r;   r
   ÚdataclassesÚ	dataclassr°   r{  ÚEnumr€  rz  rJ   Úpropertyr  r“  r•  r™  rp   r›  rÄ   r¨  r¬  Úclassmethodr³  rˆ  Úhookimplr¿  rÌ  rÑ  rÏ  rÝ  r»  rí  rð  rê  rï  rë  rö  rõ  rŸ  rä  r  r¾  r  r  r%  r  r'  r(  r+  r,  r-  r.  r/  r4  r…   r2  r5  rÐ  rì  r?   r?   r?   r@   r¨   Å  sv   


!ü=		 ý	-6!#$4.c                   C  s,   zds
t ‚W n t k
r"   Y dS X dS d S )NFT)rÚ   r?   r?   r?   r@   r6    s
    r6  zTextIO | Noner!   )ra   rÙ  rG   c                 C  sZ   t |d�}| jjdkrd|_n| jjdkr0d|_| jjdkrDd|_n| jjdkrVd|_|S )zÚCreate a TerminalWriter instance configured according to the options
    in the config object.

    Every code which requires a TerminalWriter object and has access to a
    config object should use this function.
    )rÙ  ÚyesTÚnoF)r!   r‡  ÚcolorZ	hasmarkupZcode_highlight)ra   rÙ  ru   r?   r?   r@   Úcreate_terminal_writer#  s    	
r@  )r  rG   c                 C  s2   |   ¡ } | dkrdS | dkr dS td| ›�ƒ‚dS )a  Convert a string representation of truth to True or False.

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.

    .. note:: Copied from distutils.util.
    )Úyr=  r  ÚtrueÚonÚ1T)rL  r>  ÚfÚfalseÚoffÚ0Fzinvalid truth value N)Úlowerrr   )r  r?   r?   r@   r!  ;  s    	r!  é2   )Úmaxsizez9tuple[warnings._ActionKind, str, type[Warning], str, int])rN  ÚescaperG   c             
   C  sÈ  d}t d| › d�ƒ}|  d¡}t|ƒdkrXd}t dt|ƒ› d|› d	�ƒ}t|j|d
�ƒ‚t|ƒdk rp| d¡ qXdd„ |D ƒ\}}}	}
}zt |¡}W n: tjk
rÐ } zt|jt	|ƒd
�ƒd‚W 5 d}~X Y nX zt
|	ƒ}W n< tk
�r   t ¡ }|jdd�}t|j|d
�ƒd‚Y nX |�r2|�r2t |¡}|
�rL|�rLt |
¡d }
|�r¶zt|ƒ}|dk �rntdƒ‚W nB tk
�r² } z"t|jd|›d|› �d
�ƒd‚W 5 d}~X Y nX nd}||||
|fS )zíParse a warnings filter string.

    This is copied from warnings._setoption with the following changes:

    * Does not apply the filter.
    * Escaping is optional.
    * Raises UsageError so we get nice error messages on failure.
    TzF        while parsing the following warning configuration:

          z8

        This error occurred:

        {error}
        ú:r7   zJhttps://docs.python.org/3/library/warnings.html#describing-warning-filtersz            Too many fields (z�), expected at most 5 separated by colons:

              action:message:category:module:line

            For more information please consult: z
            )ÚerrorrX  c                 s  s   | ]}|  ¡ V  qd S rH   r  )rÑ   Úsr?   r?   r@   rÕ  x  s     z'parse_warning_filter.<locals>.<genexpr>Nr£  )r^   z\Zr   znumber is negativezinvalid lineno rM   )r   rU   rI  r   rÁ   rÝ   r¡   Ú
_getactionÚ_OptionErrorrK   Ú_resolve_warning_categoryrC   r   Zfrom_currentrm   ÚrerL  ry   rr   )rN  rL  Ú__tracebackhide__Zerror_templateru  Zdoc_urlrN  Zaction_rã   Z	category_ÚmoduleZlineno_Úactionrs   Úcategoryrt   Zexception_textÚlinenor?   r?   r@   Úparse_warning_filterM  s`    ýÿ
ÿÿûÿ	(

ÿþrY  ztype[Warning])rW  rG   c                 C  sr   d}| st S d| kr"ddl}| }n |  d¡\}}}t|dd|gƒ}t||ƒ}t|t ƒsdt|› d�ƒ‚ttt  |ƒS )z§
    Copied from warnings._getcategory, but changed so it lets exceptions (specially ImportErrors)
    propagate so we can get access to their tracebacks (#9218).
    TÚ.r   Nz is not a Warning subclass)	r  ÚbuiltinsÚ
rpartitionr]  rÛ   Ú
issubclassr   r   r   )rW  rT  rÒ   ÚklassrU  r  Úcatr?   r?   r@   rR  •  s    

rR  rD   )r  r  rG   c                 C  s<   | D ]}t jt|dd�Ž  q|D ]}t jt|dd�Ž  q dS )z8Applies pytest-configured filters to the warnings moduleF)rL  TN)r¡   r  rY  )r  r  rN  r?   r?   r@   r
  «  s    r
  )NN)rŽ   r�   r�   r‘   r’   r“   r”   r•   r–   r—   r˜   r™   rš   r›   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r¥   r¦   r§   )NN)NN)N)yr;   Ú
__future__r   r…  Úcollections.abcrd  rÇ  r7  r{  Ú	functoolsr   r/  Úimportlib.metadatarT   rØ   rV   r±   rS  rè  rh   Útextwrapr   r  r   Útypingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r¡   Zpluggyr   r   r   r   r   Úcompatr   Ú
exceptionsr   r   Z	findpathsr   rß   r   Z_pytest._coder   r   Z_pytest._code.coder    Z_pytest._ior!   Z_pytest.config.argparsingr"   r$   Z_pytest.deprecatedZ_pytest.hookspecZ_pytest.outcomesr%   r&   Z_pytest.pathlibr'   r(   r)   r*   r+   r,   Z_pytest.stashr-   Z_pytest.warning_typesr.   r/   Z_pytest.cacheproviderr0   Z_pytest.terminalr1   rw  rü   r<  rò   ÚIntEnumr3   rC   rA   rX   rx   rƒ   r„   rŠ   r‹   rP  rµ   rì   rZ  r?  r¹   rº   rf   rÊ   rä   r¯   rU  rf  r'  rp  r¨   r6  r@  r!  rY  rR  r
  r?   r?   r?   r@   Ú<module>   s$  
  þ7	                          å

  þ  þ     cA      Z
 ÿG