
    g                      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 eUZV	  e(d2      ZW e*d2      ZXe G d3 d4ej                               ZZ G d5 d6e[      Z\	 	 	 	 dpd7Z]	 	 dq	 	 	 	 	 drd8Z^dsd9Z_ G d: d;      Z`dtd<Zadtd=Zbd>Zcg ecd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXZd eeed      Zfefj                  dY       efj                  dZ       	 	 dq	 	 	 	 	 dud\Zhdvd^Zi	 	 dq	 	 	 	 	 dwd_Zjdxd`Zk	 	 	 	 	 	 	 	 dydaZle G db d]e,             Zm	 	 	 	 dzdcZn G dd de      Zo eo       Zpd{dfZqe G dg d[             Zrd|dhZs	 d}	 	 	 	 	 d~diZtddjZu e
dkl      	 	 	 	 	 	 ddm       ZvddnZw	 	 	 	 	 	 ddoZxy)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                  (    e Zd ZdZdZdZdZdZdZdZ	y)	ExitCodezEncodes 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__OKTESTS_FAILEDINTERRUPTEDINTERNAL_ERRORUSAGE_ERRORNO_TESTS_COLLECTED     L/var/www/openai/venv/lib/python3.12/site-packages/_pytest/config/__init__.pyr5   r5   [   s(     
BLKNKrE   r5   c                  (    e Zd Z	 	 	 	 	 	 ddZddZy)ConftestImportFailurec                    || _         || _        y N)pathcause)selfrK   rL   s      rF   __init__zConftestImportFailure.__init__s   s     	
rE   c                z    t        | j                        j                   d| j                   d| j                   dS )N: z (from ))typerL   r:   rK   rM   s    rF   __str__zConftestImportFailure.__str__|   s3    tzz"++,Btzzl'$))ANNrE   N)rK   pathlib.PathrL   	ExceptionreturnNone)rW   str)r:   r;   r<   rN   rT   rD   rE   rF   rH   rH   r   s)     	
 
OrE   rH   c                    t        |       xr4 dt        | j                        j                  t        j
                        vS )zFilter 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    rY   rK   splitossep)entrys    rF   ,filter_traceback_for_conftest_import_failurer`      s3     E"W{#ejj/:O:OPRPVPV:W'WWrE   c                   t         j                  j                  d      }	 t        t         j                  d<   	 t	        | |      }	 |j
                  j                  |      }	 t        |      |j                          |!t         j                  j                  dd       S |t         j                  d<   S # t        $ rK |cY |j                          |!t         j                  j                  dd       S |t         j                  d<   S w xY w# |j                          w xY w# t        $ r=}t        j                  |j                        }t        t         j"                        }|j%                  d|j&                   dd       |j(                  j+                  t,              |_        |j(                  r|j/                  dd	
      n|j1                         }t3        |      }	|	j5                         D ]#  }
|j%                  |
j7                         d       % t        j8                  cY d}~|!t         j                  j                  dd       S |t         j                  d<   S d}~ww xY w# t:        $ r}t        t         j"                        }|j<                  D ]  }|j%                  d| dd        t        j8                  cY d}~|!t         j                  j                  dd       S |t         j                  d<   S d}~ww xY w# |!t         j                  j                  dd       w |t         j                  d<   w xY w)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.
    PYTEST_VERSIONconfigNz$ImportError while loading conftest 'z'.T)redshortF)stylechainzERROR: 
)r]   environgetr   _prepareconfighookpytest_cmdline_mainr5   _ensure_unconfigurepop
ValueErrorrH   r   from_exceptionrL   r"   sysstderrlinerK   	tracebackfilterr`   getreprexconlyrY   
splitlinesrstriprB   r   args)r|   pluginsold_pytest_versionrd   reteexc_infotwexc_reprformatted_tbru   msgs               rF   mainr      s    (89&>'2

#$	-#D'2F$-&,kk&E&EV&E&T#C= **, %JJNN+T2+=BJJ'( " J**, %JJNN+T2+=BJJ'( **,1 % 	($33AGG<H

+BGG:166("E4GP!)!3!3!:!:<"H
 %%   we <%%' 
 x=L$//140 2'''  %JJNN+T2+=BJJ'(E	(2  $CJJ'66CGGgcU"%4G0 ###%JJNN+T2+=BJJ'($ %JJNN+T2+=BJJ'(s   I* D  D #
B4 -I* 4D?D  I* DD DI*  
I'*C<I"&I''I* "I''I* *	L3AK?LL ?LL 8L?c                 >   	 t               } t        j                  j                          | S # t        $ rg t        j                  t
        j                  t
        j                        }t        j                  |t        j                  j                                Y yw xY w)zoThe CLI entry point of pytest.

    This function is not meant for programmable use; use `main()` instead.
    r   )r   rs   stdoutflushBrokenPipeErrorr]   opendevnullO_WRONLYdup2fileno)coder   s     rF   console_mainr      sj    	v

  ''"**bkk2
**,-s   ), A-BBc                      e Zd Z ee      Zy)cmdlineN)r:   r;   r<   staticmethodr   rD   rE   rF   r   r      s    DrE   r   c                d    t         j                  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: r]   rK   isdirr   rK   optnames     rF   filename_argr      s0     
ww}}TG9$@GHHKrE   c                d    t         j                  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   s     rF   directory_argr      s0     77==G9$A$HIIKrE   )markr   runnerfixtures
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faulthandlerpytesterpytester_assertionsConfigc           	        t               }t        |t        j                  | xs d|t        j                  j                                     }| |j                  | d       t        D ]  }|j                  |        |S )NrD   r|   r}   dirinvocation_paramsTexclude_only)	PytestPluginManagerr   InvocationParamspathlibPathcwdconsider_preparsedefault_pluginsimport_plugin)r|   r}   pluginmanagerrd   specs        rF   
get_configr     s    
 ()M 11  " 2 
F ''4'@##D)   MrE   r   c                 *    t               j                  S )zObtain 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   rD   rE   rF   get_plugin_managerr   3  s     <%%%rE   c                    | t         j                  dd  } ngt        | t        j                        rt        j
                  |       g} n6t        | t              s&d}t        |j                  | t        |                   t        | |      }|j                  }	 |r:|D ]5  }t        |t              r|j                  |       %|j                  |       7 |j                  j!                  ||       }|S # t"        $ r |j%                           w xY w)Nr   zG`args` parameter expected to be a list of strings, got: {!r} (type: {}))r   r|   )rs   argv
isinstancer]   PathLikefspathlist	TypeErrorformatrR   r   r   rY   consider_pluginargregisterrm   pytest_cmdline_parseBaseExceptionro   )r|   r}   r   rd   r   plugins         rF   rl   rl   >  s     |xx|	D"++	&		$ d#U 	 

4d455g&F((M!fc*!44V<!**62	 "
 ##88'd 9 
  ""$s   AC2 2Dc                >    | j                         r| j                  S | S )z<Get the directory of a path - itself if already a directory.)is_fileparent)rK   s    rF   _get_directoryr   ^  s    ||~{{rE   c                   t         rt        j                  |       sJ t        | dg       D ch c]  }|j                   }}g }i }|D ]Z  }t        | |t
              }|t
        ur|j                  | d|        d||<   8||v r|j                  | d       d||<   Vd||<   \ |radj                  |      }	t        j                  j                  j                  || j                  |	      }
t        t        t        |       |
       |S c c}w )N
pytestmark=Tz=TrueF, )rR   fullname	hook_opts)r   inspect	isroutinegetattrnameAttributeErrorappendjoin_pytest
deprecatedHOOK_LEGACY_MARKINGr   r<   r0   r	   r   )method	hook_type	opt_namesmknown_marks	must_warnoptsopt_nameopt_attrr   messages              rF   _get_legacy_hook_marksr   f  s   
   (((-4V\2-NO-NQVV-NKOID68^<>)z8*56!DN$z/0!DN"DN  IIi(	$$88??(( @ 

 	$|V4g>K+ Ps   D
c                      e Zd ZdZd fdZ	 	 	 	 	 	 d fdZd fdZdd fdZddZd dZ	d!dZ
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"d	Zd#d
Z	 	 	 	 	 	 	 	 	 	 d$dZ	 	 	 	 	 	 	 	 	 	 d%dZd&dZ	 	 	 	 	 	 d'dZ	 	 	 	 	 	 	 	 	 	 d(dZ	 	 	 	 	 	 d)dZdd	 	 	 	 	 d*dZd+dZ	 	 	 	 	 	 d,dZddZd-dZ	 	 	 	 d.dZd/d0dZ xZS )1r   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.
    c                   dd l }t        | 	  d       t               | _        i | _        d | _        d| _         t        d      t              | _	        g | _
        | j                  |j                         | j                  |        t        j                  j!                  d      rt"        j$                  }t'        |dd      }	 t)        t        j*                  |j-                               |j.                  d|	      }| j2                  j4                  j7                  |j8                         | j;                          |j<                  j?                         | _         d| _!        y # t0        $ r Y qw xY w)
Nr   r3   F   PYTEST_DEBUGencodingutf8r   )mode	bufferingr  )"_pytest.assertionsuperrN   set_conftest_plugins_dirpath2confmods_confcutdir_noconftestr   r   skipped_pluginsadd_hookspecshookspecr   r]   rj   rk   rs   rt   r   r   dupr   r  rV   traceroot	setwriterwriteenable_tracingr   DummyRewriteHookrewrite_hook_configured)rM   r   errr  	__class__s       rF   rN   zPytestPluginManager.__init__  s,    " 9< NP04 
 -in^< 797++,d::>>.)::C#CV<HFF3::<(%	 JJOO%%cii0! $-->>@   s   :E# #	E/.E/c                    |j                  d      sy|dk(  ryt        | 	  ||      }||S t        ||      }t	        j
                  |      syt        |dd      S ):meta private:pytest_Npytest_pluginsimpl)tryfirsttrylastoptionalhookhookwrapper)
startswithr  parse_hookimpl_optsr   r   r   r   )rM   r   r   r   r   r  s        rF   r%  z'PytestPluginManager.parse_hookimpl_opts  sn     y)##w*648K&  (%FR
 	
rE   c                    t         |   ||      }|*t        ||      }|j                  d      rt	        |dd      }|S )r  r  r   )firstresulthistoric)r  parse_hookspec_optsr   r$  r   )rM   module_or_classr   r   r   r  s        rF   r)  z'PytestPluginManager.parse_hookspec_opts  sK    w*?DA<_d3Fy)-/
 rE   c           
        |t         j                  j                  v r>t        j                  t        dj                  |j                  dd                         y t        | %  ||      }|]| j                  j                  j                  t        |||              t        |t        j                         r| j#                  |       |S )NzQ{} plugin has been merged into the core, please remove it from your requirements._-)r   plugin_namemanagerkwargs)r   r   DEPRECATED_EXTERNAL_PLUGINSr   warnr/   r   replacer  r   rm   pytest_plugin_registeredcall_historicdictr   types
ModuleTypeconsider_module)rM   r   r   r.  r  s       rF   r   zPytestPluginManager.register  s    7%%AAAMM#??EvS#.@ g&vt4"II..<<! +  =  &%"2"23$$V,rE   c                (    | j                  |      }|S rJ   )
get_plugin)rM   r   r   s      rF   	getpluginzPytestPluginManager.getplugin  s    '+t'<rE   c                6    t        | j                  |            S )z:Return whether a plugin with the given name is registered.)boolr<  )rM   r   s     rF   	haspluginzPytestPluginManager.hasplugin  s    DOOD)**rE   c                Z    |j                  dd       |j                  dd       d| _        y)r  markersztryfirst: 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.ztrylast: 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  )rM   rd   s     rF   pytest_configurez$PytestPluginManager.pytest_configure  s>     	G	
 	F	
  rE   c               >   |rt        ||z        nd| _        || _        || _        d}	|D ]Y  }
t	        |
      }|j                  d      }|dk7  r|d| }t        ||z        }t        |      sC| j                  ||||       d}	[ |	s| j                  ||||       yy)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::consider_namespace_packagesT)r(   r  r  _using_pyargsrY   findr-   _try_load_conftest)rM   r|   pyargs
noconftestrootpath
confcutdirinvocation_dir
importmoderI  foundanchorinitial_pathrK   ianchors                 rF   _set_initial_conftestsz*PytestPluginManager._set_initial_conftests!  s    ( :DL*45 	 &# L|$D		$ABwBQx!.4"78F 6"''0K	 (  ## !$ ##,G	 $  rE   c                L    | j                   y|| j                   j                  vS )z:Whether to consider the given path to load conftests from.T)r  parents)rM   rK   s     rF   _is_in_confcutdirz%PytestPluginManager._is_in_confcutdirT  s*    # 4++3333rE   c                   | j                  ||||       |j                         r=|j                  d      D ](  }|j                         s| j                  ||||       * y y )NrH  ztest*)_loadconftestmodulesis_dirglob)rM   rV  rR  rO  rI  xs         rF   rL  z&PytestPluginManager._try_load_conftestc  sn     	!!(C	 	" 	
 ==?[[)88:--" 4O	 .  * rE   c               X   | j                   ry | j                  |      }|| j                  v ry g }t        |g|j                        D ]P  }| j                  |      s|dz  }|j                         s+| j                  ||||      }	|j                  |	       R || j                  |<   y )Nzconftest.pyrH  )	r  r   r
  reversedrY  rZ  r   _importconftestr   )
rM   rK   rR  rO  rI  	directoryclistr   conftestpathmods
             rF   r\  z(PytestPluginManager._loadconftestmodules|  s     ''-	 ...	>I,=,=>?F%%f-%5'')..$" 4O	 / C LL% @ -2y)rE   c                \    | j                  |      }| j                  j                  |d      S )NrD   )r   r
  rk   )rM   rK   rc  s      rF   _getconftestmodulesz'PytestPluginManager._getconftestmodules  s+    ''-	%%)))R88rE   c                    | j                  |      }t        |      D ]  }	 |t        ||      fc S  t	        |      # t        $ r Y +w xY wrJ   )rh  ra  r   r   KeyError)rM   r   rK   modulesrf  s        rF   _rget_with_confmodz&PytestPluginManager._rget_with_confmod  sZ    
 **40G$CGC... %
 tn " s   =	A	A	c          
        t        |      }| j                  |      }|t        t        j                  |      S t        |      }|	 t        j                  |j                  = 	 t        ||||      }| j                  ||       | j                  j!                  |       |j"                  }
|
| j$                  v rj| j$                  j'                         D ]M  \  }}|
|j(                  v s||
k(  s||v rt+        d|d| d|j,                   d      |j/                  |       O | j1                  d|       | j3                  ||       |S # t        $ r Y w xY w# t        $ r!}	|	j                  J t        ||	      |	d }	~	ww xY w)	N)r  r  rI  )rL   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)rY   r<  r	   r8  r9  r,   rs   rk  stemrj  r*   rV   __traceback__rH   _check_non_top_pytest_pluginsr	  addr   r
  itemsrY  AssertionError__file__r   r  consider_conftest)rM   re  rR  rO  rI  conftestpath_plugin_nameexistingpkgpathrf  r   dirpathrK   modss                rF   rb  z#PytestPluginManager._importconftest  s    $'|#4 ??#;<(((33 '|4?KK 1 12		F,G	C 	**3=""3'%%d,,,"44::<
ddll*dgod{,A,AQ R558E9VWZWcWcVd ebb 
 KK$ = 	

,SG45s6NO
=    	F??...'A>AE	Fs*   E #E 	EE	F$F  Fc                    t        |d      rD| j                  r7| j                  s*d}t        |j	                  || j
                        d       y y y y )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)pytrace)hasattrr  rJ  r&   r   r  )rM   rf  re  r   s       rF   rq  z1PytestPluginManager._check_non_top_pytest_plugins  sX     C)*  &&w  L$*:*:;UK ' ! +rE   Fr   c               D   d}t        |      }||k  r||   }|dz  }t        |t              r^|dk(  r	 ||   }|dz  }n|j	                  d      r|dd }nH|j                         }|r|j	                  d      sl| j                  |       ||k  r~yy# t        $ r Y yw xY w)r  r   r   z-pNr6   no:)lenr   rY   
IndexErrorr$  stripr   )rM   r|   r   rU  noptpargs          rF   r   z%PytestPluginManager.consider_preparse  s     I!eq'CFA#s#$;#Aw FA^^D)qr7Dzz|(>''-# !e & s   B 	BBc                   |j                  d      r{|dd }|t        v rt        d| d      |dk(  r"| j                  d       | j                  d       | j                  |       |j                  d	      s| j                  d	|z          yy|}| j	                  |       |j                  d	      s| j	                  d	|z          | j                  |d
       y)r  r  r7   Nzplugin z cannot be disabledr   r   pytest_stepwiser  T)consider_entry_points)r$  essential_pluginsr   set_blockedunblockr   )rM   argr   s      rF   r   z&PytestPluginManager.consider_pluginarg  s    >>% qr7D(( 74&0C!DEE &  ,  !23T"??9-  T!12 . DLL??9-Y-.s$?rE   c                *    | j                  ||       y)r  r   N)r   )rM   conftestmodulern  s      rF   rv  z%PytestPluginManager.consider_conftest,  s     	n+<=rE   c                `    | j                  t        j                  j                  d             y)r  PYTEST_PLUGINSN)_import_plugin_specsr]   rj   rk   rS   s    rF   consider_envz PytestPluginManager.consider_env2  s    !!"**..1A"BCrE   c                <    | j                  t        |dg              y)r  r  N)r  r   )rM   rf  s     rF   r:  z#PytestPluginManager.consider_module6  s    !!'#/?"DErE   c                J    t        |      }|D ]  }| j                  |        y rJ   )_get_plugin_specs_as_listr   )rM   r   r}   import_specs       rF   r  z(PytestPluginManager._import_plugin_specs:  s&     ,D1"K{+ #rE   c                n   t        |t              s
J d|       | j                  |      s| j                  |      y|t        v rd|z   n|}| j
                  j                  |       |r| j                  d|      }|ry	 t        |       t        j                  |   }| j                  ||       y# t        $ r=}t        d| d|j                  d          j                  |j                        |d}~wt         $ r5}| j"                  j%                  ||j&                  xs d	f       Y d}~yd}~ww xY w)
zImport 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   rY   
is_blockedr<  builtin_pluginsr  mark_rewriteload_setuptools_entrypoints
__import__rs   rk  r   ImportErrorr|   with_tracebackrp  r'   r  r   r   )rM   modnamer  
importspecloadedrf  r   s          rF   r   z!PytestPluginManager.import_pluginA  s1    S
 	</{;	< 
 ??7#tw'?'K-4-GZ')W
&&z2 55jw5OF	(z" ++j)CMM#w'  	5*7)3qvvaykBnQ__-15  	@  ''!%%+2(>??	@s$   B2 2	D4;8C33D4?+D//D4rW   rX   )r   _PluggyPluginr   rY   rW   zHookimplOpts | None)r   rY   rW   zHookspecOpts | NonerJ   )r   r  r   
str | NonerW   r  r   rY   )r   rY   rW   r?  )rd   r   rW   rX   )r|   zSequence[str | pathlib.Path]rM  r?  rN  r?  rO  rU   rP  pathlib.Path | NonerQ  rU   rR  zImportMode | strrI  r?  rW   rX   )rK   rU   rW   r?  )
rV  rU   rR  str | ImportModerO  rU   rI  r?  rW   rX   )
rK   rU   rR  r  rO  rU   rI  r?  rW   rX   )rK   rU   rW   zSequence[types.ModuleType])r   rY   rK   rU   rW   ztuple[types.ModuleType, Any])
re  rU   rR  r  rO  rU   rI  r?  rW   types.ModuleType)rf  r  re  rU   rW   rX   )r|   Sequence[str]r   r?  rW   rX   )r  rY   rW   rX   )r  r  rn  rY   rW   rX   )rf  r  rW   rX   )r   -None | types.ModuleType | str | Sequence[str]rW   rX   )F)r  rY   r  r?  rW   rX   )r:   r;   r<   r=   rN   r%  r)  r   r=  r@  rD  rW  rZ  rL  r\  rh  rl  rb  rq  r   r   rv  r  r:  r  r   __classcell__)r  s   @rF   r   r     s   1!f
#
+.
	
42
+ *1*1 1 	1
 1 (1 %1 %1 &*1 
1f4 % 	 &* 
222 %2 	2 &*2 
2@9  
&	3"3 %3 	3 &*3 
3jLL #L 
	L6 <A.!.48.	.2@.>.>CF>	>DF,A,	,#( #(rE   c                   | g S t        | t        j                        rg S t        | t              r| r| j	                  d      S g S t        | t
        j                  j                        rt        |       S t        d|       )z:Parse a plugins specification into a list of plugin names.,zWPlugins may be specified as a sequence or a ','-separated string of plugin names. Got: )
r   r8  r9  rY   r\   collectionsabcr   r   r   )specss    rF   r  r  g  sz    
 }	%))*	%#(u{{30b0%112E{

abgajk rE   c                      e Zd Zd Zy)Notsetc                     y)Nz<NOTSET>rD   rS   s    rF   __repr__zNotset.__repr__}  s    rE   N)r:   r;   r<   r  rD   rE   rF   r  r  |  s    rE   r  c              #  @  K   t        |       } d}| D ]  }d|vxr |j                  d      }|j                  d      dk(  xr |j                  d      }|rAt        j                  j                  |      \  }}|dk7  sk|j                  d      r}d}| |st        j                  j                  |      }d}|  |sYg }| D ];  }|j                  d      }	dj                  |	dd	       }
|
s+|j                  |
       = |rt        |      E d	{    y	y	y	7 w)
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setup__editable__TN)r   endswithcountr]   rK   splitextr$  dirnamer\   r   r   _iter_rewritable_modules)package_files	seen_somefnis_simple_module
is_packagemodule_namer,  package_namenew_package_filespartsnew_fns              rF   r  r    s$    @ 'MIb=?R[[-?XXc]a'FBKK,F
WW--b1NK g%k.D.D^.T 	!!77??2.LI   BHHSMEXXeABi(F!((0	  
 /0ABBB   Cs+   A:D=D	DAD1#DDDc                     e Zd ZU dZe ej                  d       G d d                    Z G d dej                        Z
ded	<   d
d	 	 	 	 	 d?dZed@d       ZedAd       ZdBdZdCdZdCdZdDdZ	 	 	 	 	 	 dEdZ	 dF	 	 	 	 	 dGdZdHdZedId       ZdJdZ ed      dKd       ZdLdZdLdZdCdZdMdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 dNdZ dOdPdZ! ed       dQd!       Z"dCd"Z#dCd#Z$dCd$Z%dRd%Z&dSd&Z'dOdPd'Z(dTd(Z)dUd)Z*dVd*Z+dWd+Z,dVd,Z-	 	 	 	 	 	 dXd-Z.dYd.Z/e0d/fdZd0Z1dFdVd1Z2dFdVd2Z3d3Z4d4ed5<   d6Z5d4ed7<   d8Z6d4ed9<   dFd[d:Z7e8d\d;       Z9e8d]d<       Z:d^d=Z;dCd>Z<y
)_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                  N    e Zd ZU dZded<   	 ded<   	 ded<   	 	 	 	 	 	 	 	 	 d
dZy	)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.
        tuple[str, ...]r|   $Sequence[str | _PluggyPlugin] | Noner}   rU   r   c                   t         j                  | dt        |             t         j                  | d|       t         j                  | d|       y )Nr|   r}   r   )object__setattr__tuple)rM   r|   r}   r   s       rF   rN   z Config.InvocationParams.__init__  s>     tVU4[9tY8tUC0rE   N)r|   Iterable[str]r}   r  r   rU   rW   rX   )r:   r;   r<   r=   __annotations__rN   rD   rE   rF   r   r    sQ    	 J55-[		1  		1 :			1
 		1 		1rE   r   c                  z    e Zd ZdZ ej
                         Z ej
                         ZeZ ej
                         Z	y)Config.ArgsSourcezSIndicates the source of the test arguments.

        .. versionadded:: 7.2
        N)
r:   r;   r<   r=   enumautoARGSINVOCATION_DIRINCOVATION_DIR	TESTPATHSrD   rE   rF   
ArgsSourcer    s5    	 tyy{"'DIIK	rE   r  r1   cacheNr   c               `   ddl m} ddl m} |0| j                  dd t        j
                  j                               }t        j                         | _	        	 || _
        	 |} |d| d| d| j                  d	
      | _        || _        	 t               | _        	 | j                  | _        | j                  j"                  j$                  j'                  d      | _        t)        | j                  j*                        | _        i | _        d| _        i | _        g | _        | j                  j5                  | d       d| _        | j*                  j8                  j;                  t=        | j                  | j                               t>        j@                  jB                  | _"        g | _#        y )Nr   )FILE_OR_DIRr$   rD   r   z%(prog)s [options] [z] [z] [...]T)usage
processopt	_ispytestrd   pytestconfigF)parserr   r0  )$
argparsingr  r%   r   r   r   r   argparse	Namespaceoptionr   _processopt_parserr   r.   stash_storer  r  rk   r   rm   	_inicache_override_ini	_opt2dest_cleanupr   r  pytest_addoptionr6  r7  r   r  r  args_sourcer|   )rM   r   r   r  r%   _as         rF   rN   zConfig.__init__  s    	,&$ $ 5 57<<+;+;+= !6 ! ((*	
 "3	
 (Ct7;''

 +	
 W
	 jj''--2266x@
&89K9K9P9P&Q	)+,.)+24##D.9 		""00t||4;M;MN 	1 	
 ",,11!	rE   c                    | j                   S )znThe path to the :ref:`rootdir <rootdir>`.

        :type: pathlib.Path

        .. versionadded:: 6.1
        )	_rootpathrS   s    rF   rO  zConfig.rootpathB  s     ~~rE   c                    | j                   S )zXThe path to the :ref:`configfile <configfiles>`.

        .. versionadded:: 6.1
        )_inipathrS   s    rF   inipathzConfig.inipathL  s     }}rE   c                :    | j                   j                  |       y)zxAdd a function to be called when the config object gets out of
        use (usually coinciding with pytest_unconfigure).N)r  r   )rM   funcs     rF   add_cleanupzConfig.add_cleanupT  s     	T"rE   c                
   | j                   rJ d| _         t        j                         5  t        j                  d       | j                  j
                  j                  t        |              d d d        y # 1 sw Y   y xY w)NTdefaultrc   r0  )r  r   catch_warningssimplefilterrm   rD  r6  r7  rS   s    rF   _do_configurezConfig._do_configureY  s_    ####$$&!!),II&&44D<M4N '&&s   AA99Bc                   | j                   r>d| _         | j                  j                  |        g | j                  j                  _        | j
                  r/| j
                  j                         } |        | j
                  r.y y )NFrc   )r  rm   pytest_unconfigurerD  _call_historyr  rp   )rM   fins     rF   ro   zConfig._ensure_unconfigure`  sa    $DII(((579DII&&4mm--##%CE mmrE   c                X    | j                   j                  d      }|J |j                  S )Nterminalreporter)r   r<  _tw)rM   r
  s     rF   get_terminal_writerzConfig.get_terminal_writeri  s6    484F4F4Q4Q5
  +++###rE   c                f   	 | j                  |       | S # t        $ r t        | j                  dd      sd|v rddlm}  ||         t        | j                  dd      sd|v sd|v rG| j                  j                         j                          t        j                  j                  d	        w xY w)
NversionFz	--versionr   )showversionhelpz--helpz-hz8
NOTE: displaying only minimal help due to UsageError.

)parser   r   r  _pytest.helpconfigr  r  
_getparser
print_helprs   r   r  )rM   r   r|   r  s       rF   r   zConfig.pytest_cmdline_parsep  s    	JJt& %  	 t{{Iu59L:D!  VU3x47G4SW<'')446

  Q !	s
    BB0c                |   |rt        |dd      rd}nd}|j                  dt        |dd      |      }| j                  j                  ||      }t	        |      sat        |      j                  d	      D ]C  }t        j                  j                  d
| d	       t        j                  j                          E y y )N	fulltraceFlongnativeT
showlocals)funcargsr  rg   )excreprexcinfori   zINTERNALERROR> )r   rx   rm   pytest_internalerroranyrY   r\   rs   rt   r  r   )rM   r  r  rg   r  resru   s          rF   notify_exceptionzConfig.notify_exception  s    
 gfk59$*EE//gflE&JRW " 
 ii,,Wg,N3xG**40

  ?4&!;<

  " 1 rE   c                    | j                   j                  | j                  k7  rV|j                  d      ^}}| j                  |z  }t	        | j                   j                  |      }dj                  |g|      }|S )NrF  )r   r   rO  r\   r)   r   )rM   nodeidbase_path_partnodeid_partfullpathrelative_paths         rF   cwd_relative_nodeidzConfig.cwd_relative_nodeid  sn    !!%%6+1<<+=(N[}}~5H'(>(>(B(BHMMYY<<=FrE   c                    t        |      }|j                  j                  j                  |       |j	                  |d       |j                  j
                  D ]  }|j                  j                  |        |S )z$Constructor usable for subprocesses.Faddopts)r   r  __dict__updater  r}   r   r   )clsoption_dictr|   rd   r_  s        rF   fromdictargszConfig.fromdictargs  sc     D!%%k2T5)&&A  33A6 'rE   c                $   |j                   |j                  z   D ]  }|j                  | j                  |<    t	        |d      rMt	        | j
                  |j                        s,t        | j
                  |j                  |j                         y y y )Nr  )_short_opts
_long_optsdestr  r~  r  setattrr  )rM   r  r   s      rF   r  zConfig._processopt  sk    OOcnn4D#&88DNN4  5 3	"4;;1SXXs{{; 2 #rE   )r!  c                "   |j                  |j                  j                  |j                  j                  |j	                  d      |j
                  j                  |j                  d      \  }}| j                  j                  ||j                  j                  |j                  j                  |j                  |j                  j                  |j
                  j                  |j                  j                  |j	                  d             y )N	testpathsFr|   rM  r6  rQ  rO  r3  rI  )r|   rM  rN  rO  rP  rQ  rR  rI  )_decide_argsknown_args_namespacefile_or_dirrM  getinir   r   rO  r   rW  rN  rP  rR  )rM   early_configr|   r  s       rF   pytest_load_initial_conftestsz$Config.pytest_load_initial_conftests  s     )5522>>44;;"))+6'99==!** 6 
k 	1144;;#88CC!**#88CC'99==#88CC(4(;(;-) 	2 	
rE   c                   | j                   j                  |t        j                  | j                              \  }}t	        |j
                  |j                  |z   |j                  xs d | j                  j                        \  }}}|| _
        || _        || _        t        | j                        | j                   j                  d<   t        | j                         | j                   j                  d<   | j                   j#                  ddd       | j                   j#                  dd	       | j                   j#                  d
ddg        |j$                  xs d| _        y )N	namespace)inifiler|   rootdir_cmd_argrQ  rootdirrA  r*  zExtra command line optionsr|   
minversionz!Minimally required pytest versionrequired_pluginsz.Plugins that must be present for pytest to run)rR   r  rD   )r  parse_known_and_unknown_argscopyr  r   inifilenamer:  rC  r   r   r  r  inicfgrY   rO  
extra_infor  addinioverride_inir  )rM   r|   nsunknown_argsrO  r  rI  s          rF   _initinizConfig._initini  s'   <<DDDIIdkk2 E 
L %4NN,.JJ.$1155	%
!'6 "-0-?	*-0->	*I'CVLL*MN<	 	 	
  __2rE   c                
   | j                   j                  |      \  }}t        |dd      }|dk(  r1ddl}	 |j                  j                  |       }| j                  |       | j                  |       y# t        $ r d}Y w xY w)zInstall 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.
        
assertmodeplainrewriter   N)	r  rF  r   r  r   install_importhook_mark_plugins_for_rewriteSystemError_warn_about_missing_assertion)rM   r|   rM  rN  r  r   rm   s          rF   _consider_importhookzConfig._consider_importhook  s      <<DDTJLr<19$5((;;DA ..t4**40	  s   A4 4BBc                    || j                   _        t        j                  j	                  d      ryd t
        j                  j                         D        }t        |      D ]  }|j                  |        y)zGiven an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins.PYTEST_DISABLE_PLUGIN_AUTOLOADNc              3     K   | ]@  }t        d  |j                  D              r"|j                  xs g D ]  }t        |        B yw)c              3  :   K   | ]  }|j                   d k(    yw)r  N)group).0eps     rF   	<genexpr>z=Config._mark_plugins_for_rewrite.<locals>.<genexpr>.<genexpr>  s     F4Eb288z)4Es   N)r  entry_pointsfilesrY   )r^  distfiles      rF   r`  z3Config._mark_plugins_for_rewrite.<locals>.<genexpr>  sK      
:FD4E4EFF

(b( I ) :s   AA)
r   r  r]   rj   rk   r[   metadatadistributionsr  r  )rM   rm   r  r   s       rF   rU  z Config._mark_plugins_for_rewrite   se     +/'::>>:; 
!**88:
 -];Dd# <rE   c                    || j                   _        	 | j                   j                  |t        j                  | j                               | j                   `|S # | j                   `w xY w)zValidate known args.r?  )r  _config_source_hintrF  rG  r  )rM   r|   vias      rF   _validate_argszConfig._validate_args  s[    +.(	1LL55		$++ 6 6  0 0s   :A A)c          	        |r t         j                  j                  }|}||fS ||k(  r|t         j                  j                  }|r|}n_g }|D ]1  }	|j	                  t        t        j                  |	d                   3 |r%|s#|r!d}
| j                  t        |
      d       ng }|s&t         j                  j                  }t        |      g}|fS )zDecide 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)	recursivezNo files were found in testpaths; consider removing or adjusting your testpaths configuration. Searching recursively from the current directory instead.r7   
stacklevel)r   r  r  r  extendsortedr^  iglobissue_config_time_warningr/   r  rY   )rM   r|   rM  r6  rQ  rO  r3  sourceresultrK   warning_texts              rF   r8  zConfig._decide_args!  s      &&++FF2 v~/ )**44&FF )fTZZ-M&NO !* !\ )
 !:: 3L Aa ;  **99n-.v~rE   c                   |rVt         j                  j                  dd      }t        |      r+| j	                  t        j                  |      d      |z   |d d  | j                  |       |r'| j	                  | j                  d      d      |z   |d d  | j                  j                  |t        j                  | j                              | _        | j                          | j                  |       | j                   j#                  |d       t         j                  j                  d	      s| j                   j%                  d
       | j                   j'                          | j                  j                  |t        j                  | j                              | _        | j)                          | j+                          | j                  j,                  R| j.                   t1        | j.                  j2                        }nt1        | j4                        }|| j                  _        	 | j6                  j9                  | || j                         y # t:        $ ra}| j                  j<                  s| j                  j>                  r*| jA                  tC        d|jD                         d       n Y d }~y d }~ww xY w)NPYTEST_ADDOPTSr  zvia PYTEST_ADDOPTSr*  zvia addopts configr?  Fr   rZ  r  )r<  r|   r  z"could not load initial conftests: r6   rm  )#r]   rj   rk   r  rj  shlexr\   rO  r;  r  parse_known_argsrG  r  r9  _checkversionrX  r   r   r  r  _validate_plugins_warn_about_skipped_pluginsrP  r  rY   r   rO  rm   r=  rH   r  r  rr  r/   rK   )rM   r|   r*  env_addoptsrP  r   s         rF   	_preparsezConfig._preparseN  sI   **..)92>K;''K(@BVW Q 	d##DKK	$:<PQTXX G %)LL$A$ADIIdkk2 %B %
! 	!!$',,T,Fzz~~>? :::F'')$(LL$A$ADIId&?&?@ %B %
! 	 ((*$$//7||' !4!45
 /
3=D%%0	II33!T\\ 4  % 		((--1J1J1R1R ..'*LQVVH(UV  / 
 			s   ,(I 	J?AJ::J?)wrapperc              #  ^   K   	 d | j                          S # | j                          w xY wwrJ   )_validate_config_optionsrS   s    rF   pytest_collectionzConfig.pytest_collection  s&     	,))+D))+s   - -*-c                D   dd l }| j                  j                  dd       }|r~ddlm} t        |t              s|j                  | j                   d       ||       ||j                        kD  r.|j                  | j                   d| d|j                   d      y y )Nr   rD  Versionz%: 'minversion' must be a single valuez: 'minversion' requires pytest-z, actual pytest-')
r3   rI  rk   packaging.versionr  r   rY   r   r  r   )rM   r3   minverr  s       rF   rz  zConfig._checkversion  s    t41fc*''||n$IJ  v););!<<''||n$CF8K[\b\n\n[oopq  = rE   c                j    t        | j                               D ]  }| j                  d| d        y )NzUnknown config option: ri   )rp  _get_unknown_ini_keys_warn_or_fail_if_strict)rM   keys     rF   r  zConfig._validate_config_options  s2    $4467C((+B3%r)JK 8rE   c                j   t        | j                  d            }|sy ddlm} ddlm} ddlm} | j                  j                         }|D ci c]  \  }}|j                  |j                   }}}g }	|D ]m  }
	  ||
      }|j                  |vr|	j                  |
       ,|j                  j                   |||j                           d      r]|	j                  |
       o |	r)t        dj!                  d	j#                  |	                  y c c}}w # |$ r |	j                  |
       Y w xY w)
NrE  r   )InvalidRequirement)Requirementr  T)prereleaseszMissing required plugins: {}r   )rp  r;  packaging.requirementsr  r  r  r  r   list_plugin_distinfoproject_namer  r   r   	specifiercontainsr   r   r   )rM   rE  r  r  r  plugin_infor,  rc  plugin_dist_infomissing_pluginsrequired_pluginreqs               rF   r{  zConfig._validate_plugins  s0   !$++.@"AB 	>6-((==?KVW;4D--t||;;W/O!/2
 xx//&&7]]++(23 ,   &&7  0 .55dii6PQ  # X & &&7s   !D;DD21D2c                ~    | j                   j                  rt        |      | j                  t	        |      d       y )Nr7   rm  )r9  strict_configr   rr  r/   )rM   r   s     rF   r  zConfig._warn_or_fail_if_strict  s6    $$22W%%&&':7'CPQ&RrE   c                v    | j                   j                  }| j                  D cg c]	  }||vs| c}S c c}w rJ   )r  _inidictrI  )rM   parser_inicfgr   s      rF   r  zConfig._get_unknown_ini_keys  s4    --!%JM0IJJJs   	66c                :   | j                   g k(  sJ d       | j                  j                  j                  t	        | j
                               | j                  ||       d| j                  _        	 | j                  j                  || j                  | j                        }| j                  || j                  j                  | j                  d      | j                  j                   | j"                  d      \  | _         | _        y # t&        $ r Y y w xY w)	Nz:can only parse cmdline args at most once per Config object)r   r0  r)  Tr?  r6  r7  )r|   rm   pytest_addhooksr6  r7  r   r~  r  after_preparseparse_setoptionr  r8  r9  rM  r;  r   r   rO  r  r   )rM   r|   r*  s      rF   r  zConfig.parse  s    IIO	HG	H		!!//d&8&89 	0 	
 	tW-&*#	<<//dkkT[[ 0 D +/*;*;0077++k2#5599 +< +'DIt'  		s   6BD 	DDc                |   | j                   j                  d      ry| j                  j                  xs g }| j	                  d      }t        j                  d      5 }t        j                  dt        |             t        ||       t        j                  ||       ddd       rt        j                  |dz
        }|j                  j                  |j                  |j                  j                   f}| j"                  j$                  j'                  t)        |d	   d
d|             yy# 1 sw Y   xY w)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alwaysrm  r   r   rd   r  )warning_messagewhenr"  locationr0  )r   r  r9  pythonwarningsr;  r   r  r  rR   apply_warning_filtersr3  rs   	_getframef_codeco_filenamef_linenoco_namerm   pytest_warning_recordedr6  r7  )rM   warningrn  cmdline_filtersconfig_filtersrecordsframer  s           rF   rr  z Config.issue_config_time_warning  s     ((433BBHb%56$$D1W!!(DM:!./BMM'j9 2
 MM*q.1E||//AUAUUHII--;;$+AJ!%	 <   21s   AD22D;c                l    | j                  |      }t        |t              sJ |j                  |       y)zAdd 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   )rM   r   ru   r_  s       rF   rC  zConfig.addinivalue_line
  s-     KK!T"""	rE   c                    	 | j                   |   S # t        $ r% | j                  |      x| j                   |<   }|cY S w xY w)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.
        )r  rj  _getini)rM   r   vals      rF   r;  zConfig.getini  sF    8	>>$'' 	)-d);;DNN4 3J	s    +??c                $    d| }t        ||      )Nzunknown configuration type: )rq   )rM   r   rR   valuer   s        rF   _getini_unknown_typezConfig._getini_unknown_type6  s    ,TF3e$$rE   c                X   	 | j                   j                  |   \  }}}| j	                  |      }|	 | j
                  |   }n|}|dk(  rr| j                  | j                  j                  n| j                  j                  }t        |t              rt        j                  |      n|}	|	D 
cg c]  }
||
z  	 c}
S |dk(  r't        |t              rt        j                  |      S |S |dk(  r?t        |t              r-t        d |j                  d            D cg c]  }|s|	 c}S |S |dk(  r"t        t        |      j!                               S |dk(  r|S ||S | j#                  |||      S # t        $ r}t        d|      |d }~ww xY w# t        $ r |cY S w xY wc c}
w c c}w )	Nzunknown configuration value: pathsr|   linelistc                "    | j                         S rJ   r  )r_  s    rF   <lambda>z Config._getini.<locals>.<lambda>b  s
    rE   ri   r?  string)r  r  rj  rq   _get_override_ini_valuerI  r  r   r   r   r   rY   rx  r\   map
_strtoboolr  r  )rM   r   descriptionrR   r  r   override_valuer  dpinput_valuesr_  ts               rF   r  zConfig._getini:  s   	N)-)>)>t)D&Kw 55d;!D) #E  7? <<+ ##++// 
 2<E31G5;;u-UL$01LqBFL11V^)3E3)?5;;u%JUJZ%%#&':EKK<M#NT#NaRS#NTTV^c%j..011XL\L,,T4??_  	N<THEFAM	N  4 2
 Us:   E1 F -F"F'#F'1	F:F		FFFc                   	 | j                   j                  ||      \  }}|j                  J t	        j
                  |j                        j                  }g }|D ]q  }t        |t        j                        rt	        j
                  |      }n.|j                  dt        j                        }t        ||z        }|j                  |       s |S # t        $ r Y y w xY w)Nr  )r   rl  rj  ru  r   r   r   r   r]   r   r4  r^   r(   r   )rM   r   rK   rf  relrootsmodpathvaluesrelroots           rF   _getconftest_pathlistzConfig._getconftest_pathlistn  s    	 ..AA$MMC ||''',,s||,33%'G'2;;/!,,w/!//#rvv6&w'89MM'"     		s   C 	CCc                    d }| j                   D ]   }	 |j                  dd      \  }}||k(  s|}" |S # t        $ r}t        d|d      |d }~ww xY w)Nr   r   z3-o/--override-ini expects option=value style (got: z).)r  r\   rq   r   )rM   r   r  
ini_configr  user_ini_valuer   s          rF   r  zConfig._get_override_ini_value  sy     ,,J+&0&6&6sA&>#^ $;*E -    I*WYZs   4	AAAFc                   | j                   j                  ||      }	 t        | j                  |      }||rt	        |      |S # t        $ r>}|t
        ur|cY d}~S |rddl}|j                  d|d       t        d|      |d}~ww xY w)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  rk   r   r  r   notsetr3   skiprq   )rM   r   r  r  r  r   r3   s          rF   	getoptionzConfig.getoption  s     ~~!!$-	A$++t,C{t$T**J 	Af$c$78/x89q@	As#   &A 	B	BB*BBc                $    | j                  |      S )z$Deprecated, use getoption() instead.r  rM   r   rK   s      rF   getvaluezConfig.getvalue  s    ~~d##rE   c                (    | j                  |d      S )z-Deprecated, use getoption(skip=True) instead.T)r  r  r  s      rF   getvalueorskipzConfig.getvalueorskip  s    ~~d~..rE   
assertionsr
   VERBOSITY_ASSERTIONS
test_casesVERBOSITY_TEST_CASESr  _VERBOSITY_INI_DEFAULTc                   | j                  dd      }t        |t              sJ ||S t        j	                  |      }|| j
                  j                  vr|S | j                  |      }|t        j                  k(  r|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  )	r  r   intr   _verbosity_ini_namer  r  r;  r  )rM   verbosity_typeglobal_levelini_namelevels        rF   get_verbosityzConfig.get_verbosity  s    > ~~i~;,,,,!--n=4<<000H%F1115zrE   c                    d|  S )N
verbosity_rD   )r  s    rF   r  zConfig._verbosity_ini_name  s    N+,,rE   c                p    | j                  t        j                  |      |dt        j                         y)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  rR   r  N)rK  r   r  r  )r  r  r  s      rF   _add_verbosity_inizConfig._add_verbosity_ini  s2     	&&~611	 	 	
rE   c                f    t               s'|dk(  rd}nd}| j                  t        |      d       y y )NrR  zRASSERTIONS ARE NOT EXECUTED and FAILING TESTS WILL PASS.  Are you using python -O?zassertions 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?)
r7   rm  )_assertion_supportedrr  r/   )rM   r  ru  s      rF   rW  z$Config._warn_about_missing_assertion  sH    #%w( 3  **#L1 +  &rE   c           	         | j                   j                  D ]'  \  }}| j                  t        d|d|       d       ) y )Nzskipped plugin rP   r6   rm  )r   r  rr  r/   )rM   r  r   s      rF   r|  z"Config._warn_about_skipped_plugins  sI     $ 2 2 B BK**#ok_Bse$LM +  !CrE   )r   r   r   zInvocationParams | NonerW   rX   )rW   rU   )rW   r  )r  zCallable[[], None]rW   rX   r  )rW   r"   )r   r   r|   	list[str]rW   r   rJ   )r  zExceptionInfo[BaseException]r  zargparse.Namespace | NonerW   rX   )r"  rY   rW   rY   )rW   r   )r  r#   rW   rX   )r<  r   rW   rX   )r|   r  rW   rX   )r|   r  ri  rY   rW   r  )r|   r  rM  r?  r6  r  rQ  rU   rO  rU   r3  r?  rW   ztuple[list[str], ArgsSource])T)r|   r  r*  r?  rW   rX   )rW   zGenerator[None, object, object])r   rY   rW   rX   )rW   r  )r  Warningrn  r  rW   rX   )r   rY   ru   rY   rW   rX   r  )r   rY   rR   rY   r  zstr | list[str])r   rY   rK   rU   rW   zlist[pathlib.Path] | None)r   rY   rW   r  )r   rY   r  r?  )r  r  rW   r  )r  rY   rW   rY   )r  r%   r  rY   r  rY   rW   rX   )r  rY   rW   rX   )=r:   r;   r<   r=   r   dataclasses	dataclassr   r  Enumr  r  rN   propertyrO  r  r  r  ro   r  r   r   r'  classmethodr/  r  hookimplr=  rO  rX  rU  rj  r8  r~  r  rz  r  r{  r  r  r  rr  rC  r;  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  rW  r|  rD   rE   rF   r   r     s}    [$'1 1 ( 1B TYY   L 6:	;"*;" 3	;"
 
;"z    #
O$08A	8 -1#-# *# 
	#$	  < d
 
4321($*
+ + 	+
 + %+ + + 
&+Z4l d, ,$LBSK2!F H%2@h+	"&" ,2 A2$/
 #/%.".%.$*E*,\ - - 
 
"*rE   c                 &    	 J # t         $ r Y yw xY w)NT)rt  rD   rE   rF   r  r    s    u s    	c                $   t        |      }| j                  j                  dk(  rd|_        n | j                  j                  dk(  rd|_        | j                  j                  dk(  r	d|_        |S | j                  j                  dk(  rd|_        |S )zCreate 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.
    )rd  yesTnoF)r"   r  color	hasmarkupcode_highlight)rd   rd  r   s      rF   create_terminal_writerr  #  s     
T	"B}}e#				$}}##u,  I 
	%	%	-!IrE   c                R    | j                         } | dv ry| dv ryt        d|       )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)r  r  ffalseoff0Fzinvalid truth value )lowerrq   )r  s    rF   r  r  ;  s:     ))+C
22	5	5/w788rE   2   )maxsizec          	        d}t        d|  d      }| j                  d      }t        |      dkD  r8d}t        dt        |       d| d	      }t        |j	                  |
            t        |      dk  r |j                  d       t        |      dk  r d |D        \  }}}	}
}	 t        j                  |      }	 t        |	      }|r|rt        j                   |      }|
r|rt        j                   |
      dz   }
|r	 t#        |      }|dk  rt%        d      nd}||||
|fS # t        j                  $ r*}t        |j	                  t        |      
            dd}~ww xY w# t        $ rC t        j                         }|j                  d      }t        |j	                  |
            dw xY w# t$        $ r'}t        |j	                  d|d| 
            dd}~ww xY w)zParse 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}
        :r9   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
            )errorr  c              3  <   K   | ]  }|j                           y wrJ   r  )r^  ss     rF   r`  z'parse_warning_filter.<locals>.<genexpr>x  s     3Mu!AGGIus   Nr  )rg   z\Zr   znumber is negativezinvalid lineno rP   )r   r\   r  r   r   r   r   
_getaction_OptionErrorrY   _resolve_warning_categoryrV   r   from_currentrx   reescaper  rq   )r  r  __tracebackhide__error_templater  doc_urlr  action_r   	category_modulelineno_actionr   categoryr   exception_textlinenos                     rF   parse_warning_filterr(  M  s*     % 		
N IIcNE
5zA~X 	 !%j\ *2 3: ;
 ..U.;<<
e*q.R e*q.3Mu3M0GWiH'/':':7'CP";I"F
 6))G$&6"U*	\Fz !566  7Hff44/    H..SV.<=4GH  P --/!)))9..^.DE4OP  	%%og[1#,N%O	s=   'D% =E%  F4 %E"8%EE"%AF14	G$="GG$c                    d}| st         S d| vrddl}| }n$| j                  d      \  }}}t        |dd|g      }t	        ||      }t        |t               st        | 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   )r%  r  r   klassr"  r,  cats          rF   r  r    s    
 
(#..s35vtTE73
!U
Cc7#C5 :;<<Ws##rE   c                    | D ]  }t        j                  t        |d        ! |D ]  }t        j                  t        |d        ! y)z8Applies pytest-configured filters to the warnings moduleF)r  TN)r   r  r(  )r  r  r  s      rF   r  r    sF     !5c%!HI  !5c$!GH rE   )r_   z_pytest._code.TracebackEntryrW   r?  )NN)r|   #list[str] | os.PathLike[str] | Noner}   r  rW   zint | ExitCode)rW   r  )rK   rY   r   rY   rW   rY   )r|   zlist[str] | Noner}   r  rW   r   )rW   r   )r|   r1  r}   r  rW   r   )rK   rU   rW   rU   )r   r   r   rY   r   r  rW   zdict[str, bool])r  r  rW   r  )r  r  rW   zIterator[str])rW   r?  rJ   )rd   r   rd  zTextIO | NonerW   r"   )r  rY   rW   r?  )r  rY   r  r?  rW   z9tuple[warnings._ActionKind, str, type[Warning], str, int])r%  rY   rW   ztype[Warning])r  r  r  r  rW   rX   )yr=   
__future__r   r  collections.abcr  rG  r  r  	functoolsr   r^  importlib.metadatar[   r   r]   r   r  rx  rs   textwrapr   r8  r   typingr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   pluggyr   r   r   r   r   compatr   
exceptionsr   r   	findpathsr   r   r   _pytest._coder   r    _pytest._code.coder!   _pytest._ior"   _pytest.config.argparsingr#   r%   _pytest.deprecated_pytest.hookspec_pytest.outcomesr&   r'   _pytest.pathlibr(   r)   r*   r+   r,   r-   _pytest.stashr.   _pytest.warning_typesr/   r0   _pytest.cacheproviderr1   _pytest.terminalr2   r  r  r  r  IntEnumr5   rV   rH   r`   r   r   r   r   r   r  r   r  r  rr  r   r   rl   r   r   r   r  r  r  r  r   r  r  r  r(  r  r  rD   rE   rF   <module>rI     s1   @ "          	  	  
                    !  !    & . 0 &   ' * - & . ,   ! $ ( ' ' & 0 '  5 3 +1  (#(# t||  ,OI OX'X	X 15484>
-4>14> 4>n$    	
             !" #$ %& '( )* +, -. /0 12 34 56 7< o&   J    ) * "48
1 2& 1548
-1 @  	@ ](- ]( ](@8* 
 
>CB Q Q Qh +/'09$ 2D5	D5D5>D5 D5N$,
I!
I4A
I	
IrE   