
    [Fi                    <   d 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m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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,m0Z0 ddl,m1Z1 dd l2m3Z3 dd!l4m5Z5 dd"l4m6Z6 dd#l7m8Z8 dd$l9m:Z: ddl;Z9dd%l;m<Z< dd&l;m=Z= dd'l>m?Z? ddl@Z9ddlAZ9dd(lBmCZC dd)lBmDZD dd*lEmFZF dd+lEmGZG dd,lEmHZH dd-lEmIZI dd.lEmJZJ dd/lEmKZK dd0lLmMZM dd1lNmOZO dd2lNmPZP e)rdd3lQmRZR dd4lQmSZS dd5lTmUZU dd6lVmWZW eXZY	  e-d7      ZZ e/d7      Z[e G d8 d9ej                               Z] G d: d;e^      Z_d<e9j                  j                  d=ebfd>Zc	 	 dd?e#e*e"ed   d@f      dAe#e$e*edeYf         d=e*eee]f   fdBZfd=eefdCZg G dD dE      ZhdFeddGedd=edfdHZidFeddGedd=edfdIZjdJZkg ekdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcddZl emel      Znenj                  de       enj                  df       	 	 dd?e#e"ed      dAe#e$e*edeYf         d=dgfdhZpddjZq	 	 dd?e#e*e"ed   d@f      dAe#e$e*edeYf         d=dgfdkZrdFed=efdlZsdmedneddoe'eddpf   d=eedebf   fdqZte G dr die1             Zudse*dej                  ede$ed   f   d=e"ed   fdtZw G du dv      Zx ex       Zydwe ed   d=e!ed   fdxZze G dy dg             Z{d=ebfdzZ|	 dd{e{d|e#e&   d=e?fd}Z}d~edd=ebfdZ~ ed      deddebd=e'dede(e   edeef   fd       Zdedd=e(e   fdZde ed   de ed   d=dfdZy)z:Command line options, ini-file and conftest.py processing.    N)	lru_cache)Path)dedent)FunctionType)Any)Callable)cast)Dict)Final)final)	Generator)IO)Iterable)Iterator)List)Optional)Sequence)Set)TextIO)Tuple)Type)TYPE_CHECKING)Union)HookimplMarker)HookimplOpts)HookspecMarker)HookspecOpts)PluginManager   )PathAwareHookProxy)	PrintHelp)
UsageError)determine_setup)__version__)ExceptionInfo)filter_traceback)TerminalWriter)fail)Skipped)absolutepath)bestrelpath)import_path)
ImportMode)resolve_package_path)safe_exists)Stash)PytestConfigWarning)warn_explicit_for)ArgumentParser)_TracebackStyle)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     i/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/_pytest/config/__init__.pyr:   r:   ^   s(     
BLKNKrJ   r:   c                   ,    e Zd ZdededdfdZdefdZy)ConftestImportFailurepathcausereturnNc                     || _         || _        y N)rN   rO   )selfrN   rO   s      rK   __init__zConftestImportFailure.__init__v   s     	
rJ   c                 z    t        | j                        j                   d| j                   d| j                   dS )N: z (from ))typerO   r?   rN   rS   s    rK   __str__zConftestImportFailure.__str__   s3    tzz"++,Btzzl'$))ANNrJ   )r?   r@   rA   r   	ExceptionrT   strrZ   rI   rJ   rK   rM   rM   u   s1     	
 
O OrJ   rM   entryrP   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&   r\   rN   splitossep)r]   s    rK   ,filter_traceback_for_conftest_import_failurerc      s3     E"W{#ejj/:O:OPRPVPV:W'WWrJ   argszos.PathLike[str]pluginsc                    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: 
)ra   environgetr$   _prepareconfighookpytest_cmdline_mainr:   _ensure_unconfigurepop
ValueErrorrM   r%   from_exceptionrO   r'   sysstderrlinerN   	tracebackfilterrc   getreprexconlyr\   
splitlinesrstriprG   r"   rd   )rd   re   old_pytest_versionri   reteexc_infotwexc_reprformatted_tbrz   msgs               rK   mainr      s    (89(>'2

#$	-#D'2F$	-,2KK,K,K! -L -#C= **, %JJNN+T2+=BJJ'( " J**, %JJNN+T2+=BJJ'( **,5 % 	($33AGG<H

+BGG:166("E4GP!)!3!3!:!:<"H
 %%   we <%%' 
 x=L$//1 1401'''$ %JJNN+T2+=BJJ'(I	(6  $CJJ'66 	1CGGgcU"%4G0	1###%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   rx   stdoutflushBrokenPipeErrorra   opendevnullO_WRONLYdup2fileno)coder   s     rK   console_mainr      sj    	v

  ''"**bkk2
**,-s   ), A-BBc                       e Zd Z ee      Zy)cmdlineN)r?   r@   rA   staticmethodr   rI   rJ   rK   r   r      s    DrJ   r   rN   optnamec                 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: ra   rN   isdirr"   rN   r   s     rK   filename_argr      s0     
ww}}TG9$@GHHKrJ   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     rK   directory_argr      s0     77==G9$A$HIIKrJ   )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                  | d       t        D ]  }|j                  |        |S )NrI   rd   re   dirinvocation_paramsTexclude_only)PytestPluginManagerr   InvocationParamsr   cwdconsider_preparsedefault_pluginsimport_plugin)rd   re   pluginmanagerri   specs        rK   
get_configr     s~    
 ()M 11
 2 
F ''4'@ *##D)* MrJ   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   rI   rJ   rK   get_plugin_managerr   8  s     <%%%rJ   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   rd   )rx   argv
isinstancera   PathLikefspathlist	TypeErrorformatrX   r   r   r\   consider_pluginargregisterrr   pytest_cmdline_parseBaseExceptionrt   )rd   re   r   ri   r   plugins         rK   rq   rq   C  s     |xx|	D"++	&		$ d#U 	 

4d455g&F((M! 3fc*!44V<!**62	3
 ##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)rN   s    rK   _get_directoryr   c  s    ||~{{rJ   method	hook_type	opt_names.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, )rX   fullname	hook_opts)r   inspect	isroutinegetattrnameAttributeErrorappendjoin_pytest
deprecatedHOOK_LEGACY_MARKINGr   rA   r2   r	   r   )r   r   r   mknown_marks	must_warnoptsopt_nameopt_attrr   messages              rK   _get_legacy_hook_marksr   k  s   
   (((-4V\2-NOQVVOK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d1 fdZdededee   f fdZ	dedee
   f fdZ	 d2dedee   dee   f fd	Zdefd
ZdedefdZd3dZdeeeef      dedededee   dedeeef   deddfdZdedefdZdedeeef   dededdf
dZdedeeef   dededdf
dZdedeej4                     fdZdededeej4                  ef   fdZdedeeef   dededej4                  f
dZdej4                  deddfd Z d!d"dee   d#eddfd$Z!d%eddfd&Z"d'ej4                  d(eddfd)Z#d1d*Z$dej4                  ddfd+Z%d,edej4                  eee   f   ddfd-Z&d4d.ed/eddfd0Z' xZ(S )5r   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.
    rP   Nc                    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   r8   F   PYTEST_DEBUGencodingutf8r   )mode	bufferingr  )"_pytest.assertionsuperrT   set_conftest_plugins_dirpath2confmods_confcutdir_noconftestr   r   skipped_pluginsadd_hookspecshookspecr   ra   ro   rp   rx   ry   r   r   dupr   r  r[   traceroot	setwriterwriteenable_tracingr   DummyRewriteHookrewrite_hook_configured)rS   r   errr  	__class__s       rK   rT   zPytestPluginManager.__init__  s,    " 9< FH+/ 
 -in^< 797++,d::>>.)::C#CV<HFF3::<(%	 JJOO%%cii0! $-->>@   s   :E# #	E/.E/r   r   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   )rS   r   r   r   r   r  s        rK   r&  z'PytestPluginManager.parse_hookimpl_opts  sn     y)##w*648K&  (%FR
 	
rJ   c                     t         |   ||      }|*t        ||      }|j                  d      rt	        |dd      }|S )r  r  r   )firstresulthistoric)r  parse_hookspec_optsr   r%  r   )rS   module_or_classr   r   r   r  s        rK   r*  z'PytestPluginManager.parse_hookspec_opts  sK    w*?DA<_d3Fy)-/
 rJ   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   warnr1   r   replacer  r   rr   pytest_plugin_registeredcall_historicdictr   types
ModuleTypeconsider_module)rS   r   r   r/  r  s       rK   r   zPytestPluginManager.register  s     7%%AAAMM#??EvS#.@ g&vt4"II..<<! +  =  &%"2"23$$V,rJ   c                 (    | j                  |      }|S rR   )
get_plugin)rS   r   r   s      rK   	getpluginzPytestPluginManager.getplugin
  s    *.//$*?rJ   c                 6    t        | j                  |            S )z:Return whether a plugin with the given name is registered.)boolr=  )rS   r   s     rK   	haspluginzPytestPluginManager.hasplugin  s    DOOD)**rJ   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  )rS   ri   s     rK   pytest_configurez$PytestPluginManager.pytest_configure  s>     	G	
 	F	
  rJ   rd   pyargs
noconftestrootpath
confcutdirinvocation_dir
importmodeconsider_namespace_packagesc                >   |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.
        NFz::rL  T)r*   r  r  _using_pyargsr\   findr/   _try_load_conftest)rS   rd   rF  rG  rH  rI  rJ  rK  rL  foundanchorintitial_pathrN   ianchors                 rK   _set_initial_conftestsz*PytestPluginManager._set_initial_conftests(  s    ( :DL*45 	 &#! 	#M}%D		$ABwBQx!.4"78F 6"''0K	 (  ##	#$ ##,G	 $  rJ   rN   c                 L    | j                   y|| j                   j                  vS )z:Whether to consider the given path to load conftests from.T)r  parents)rS   rN   s     rK   _is_in_confcutdirz%PytestPluginManager._is_in_confcutdir[  s*    # 4++3333rJ   rV  c                    | j                  ||||       |j                         r=|j                  d      D ](  }|j                         s| j                  ||||       * y y )NrO  ztest*)_loadconftestmodulesis_dirglob)rS   rV  rK  rH  rL  xs         rK   rR  z&PytestPluginManager._try_load_conftestj  ss     	!!(C	 	" 	
 ==?[[) 88:--" 4O	 .  rJ   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.pyrO  )	r  r   r  reversedrY  rZ  r   _importconftestr   )
rS   rN   rK  rH  rL  	directoryclistr   conftestpathmods
             rK   r\  z(PytestPluginManager._loadconftestmodules  s     ''-	 ...	>I,=,=>? 
	&F%%f-%5'')..$" 4O	 / C LL%
	& -2y)rJ   c                 \    | j                  |      }| j                  j                  |d      S )NrI   )r   r  rp   )rS   rN   rc  s      rK   _getconftestmodulesz'PytestPluginManager._getconftestmodules  s+    ''-	%%)))R88rJ   c                     | j                  |      }t        |      D ]  }	 |t        ||      fc S  t	        |      # t        $ r Y +w xY wrR   )rh  ra  r   r   KeyError)rS   r   rN   modulesrf  s        rK   _rget_with_confmodz&PytestPluginManager._rget_with_confmod  s_    
 **40G$ 	CGC...	
 tn " s   =	A	A	re  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  rL  )rO   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)r\   r=  r	   r9  r:  r.   rx   rk  stemrj  r,   r[   __traceback__rM   _check_non_top_pytest_pluginsr
  addr   r  itemsrY  AssertionError__file__r   r  consider_conftest)rS   re  rK  rH  rL  conftestpath_plugin_nameexistingpkgpathrf  r   dirpathrN   modss                rK   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rf  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  rP  r(   r   r  )rS   rf  re  r   s       rK   rq  z1PytestPluginManager._check_non_top_pytest_plugins  sX     C)*  &&w  L$*:*:;UK ' ! +rJ   Fr   r   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-pNr;   no:)lenr   r\   
IndexErrorr%  stripr   )rS   rd   r   rU  noptpargs          rK   r   z%PytestPluginManager.consider_preparse  s     I!eq'CFA#s#$;#Aw FA^^D)qr7Dzz|(>''-# !e & s   B 	BBargc                    |j                  d      rz|dd }|t        v rt        d|z        |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  r<   Nzplugin %s cannot be disabledr   r   pytest_stepwiser  T)consider_entry_points)r%  essential_pluginsr"   set_blockedunblockr   )rS   r  r   s      rK   r   z&PytestPluginManager.consider_pluginarg  s    >>% qr7D(( !?$!FGG &  ,  !23T"??9-  T!12 . DLL??9-Y-.s$?rJ   conftestmodulern  c                 *    | j                  ||       y)r  r   N)r   )rS   r  rn  s      rK   rv  z%PytestPluginManager.consider_conftest3  s     	n+<=rJ   c                 `    | j                  t        j                  j                  d             y)r  PYTEST_PLUGINSN)_import_plugin_specsra   ro   rp   rY   s    rK   consider_envz PytestPluginManager.consider_env9  s    !!"**..1A"BCrJ   c                 <    | j                  t        |dg              y)r  r  N)r  r   )rS   rf  s     rK   r;  z#PytestPluginManager.consider_module=  s    !!'#/?"DErJ   r   c                 J    t        |      }|D ]  }| j                  |        y rR   )_get_plugin_specs_as_listr   )rS   r   re   import_specs       rK   r  z(PytestPluginManager._import_plugin_specsA  s+     ,D1" 	,K{+	,rJ   modnamer  c                 n   t        |t              s
J d|z         | 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 %rNz_pytest.pytest11r  zError importing plugin "z": r    )r   r\   
is_blockedr=  builtin_pluginsr  mark_rewriteload_setuptools_entrypoints
__import__rx   rk  r   ImportErrorrd   with_tracebackrp  r)   r  r   r   )rS   r  r  
importspecloadedrf  r   s          rK   r   z!PytestPluginManager.import_pluginH  s*    '3' 	
2W<	
' ??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rP   NrR   )ri   r   rP   N)F))r?   r@   rA   rB   rT   _PluggyPluginr\   r   r   r&  r   r*  r   r>  r@  rA  rE  r   r   r   r-   rW  rZ  rR  r\  r9  r:  rh  r   r   rl  rb  rq  r   r   rv  r  r;  r  r   __classcell__)r  s   @rK   r   r     s)   1!f
#
+.
	,	
4 ,AW  <@#+3C=	#6c 
+c +d + *1uS$Y'(1 1 	1
 1 TN1 1 *c/*1 &*1 
1f4d 4t 4 #z/* 	 &* 
222 #z/*2 	2 &*2 
2@9 9%:J:J1K 9  
u$	%	33 #z/*3 	3 &*3 
		3jLL L 
	L6 <A.SM.48.	.2@c @d @.>#..>CF>	>DF5#3#3 F F,$ 0 0#x}DE,	,#(S #( #(RV #(rJ   specsc                    | 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        )z:Parse a plugins specification into a list of plugin names.,zYPlugins may be specified as a sequence or a ','-separated string of plugin names. Got: %r)
r   r9  r:  r\   r`   collectionsabcr   r   r"   )r  s    rK   r  r  n  sy    
 }	%))*	%#(u{{30b0%112E{
c
	 rJ   c                       e Zd Zd Zy)Notsetc                      y)Nz<NOTSET>rI   rY   s    rK   __repr__zNotset.__repr__  s    rJ   N)r?   r@   rA   r  rI   rJ   rK   r  r    s    rJ   r  package_filesc              #   @  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countra   rN   splitextr%  dirnamer`   r   r   _iter_rewritable_modules)r  	seen_somefnis_simple_module
is_packagemodule_namer-  package_namenew_package_filespartsnew_fns              rK   r  r    s.    @ 'MI b=?R[[-?XXc]a'FBKK,F
WW--b1NK g%k.D.D^.T 	!!77??2.LI   	1BHHSMEXXeABi(F!((0		1
 /0ABBB   Cs+   A:D=D	DAD1#DDDc                   B   e Zd ZU dZe ej                  d       G d d                    Z G d dej                        Z
dd	d
edee   ddfdZedefd       Zedee   fd       Zdeg df   ddfdZdYdZdYdZdefdZd
edee   dd fdZ	 dZdee   deej<                     ddfdZdedefdZ e!d[d       Z"d\dZ# e$d      d]d       Z%de&e   ddfd Z'de&e   ddfd!Z(dYd"Z)dee   d#edee   fd$Z*dee   d%e+d&ee   d'ed(ed)e+de,ee   e
f   fd*Z-d^dee   d+e+ddfd,Z. e$d-      de/de0e0f   fd.       Z1dYd/Z2dYd0Z3dYd1Z4d2eddfd3Z5dee   fd4Z6d^dee   d+e+ddfd5Z7d6e8d7e9ddfd8Z:d9ed:eddfd;Z;d9efd<Z<d9ed=ed>e=eee   f   fd?Z>d9efd@Z?d9edAedeee      fdBZ@d9edee   fdCZAeBdDfd9edEe+fdFZCdZd9efdGZDdZd9efdHZEdIZFeGeHdJ<   dKZIeGeHdL<   dMZJeGeHdN<   dZdOee   de9fdPZKeLdOedefdQ       ZMeLdRdSdOedTeddfdU       ZNdVeddfdWZOdYdXZPy)_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                       e Zd ZU dZeedf   ed<   	 eee	ee
f         ed<   	 eed<   	 dee   deee	ee
f         deddf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.
        .rd   re   r   rP   Nc                    t         j                  | dt        |             t         j                  | d|       t         j                  | d|       y )Nrd   re   r   )object__setattr__tuple)rS   rd   re   r   s       rK   rT   z Config.InvocationParams.__init__  s>     tVU4[9tY8tUC0rJ   )r?   r@   rA   rB   r   r\   __annotations__r   r   r   r  r   r   rT   rI   rJ   rK   r   r    s    	 CHoJ(5m);#<=>>-	G		1 3-		1 huS--?'@AB			1
 		1 		1rJ   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@   rA   rB   enumautoARGSINVOCATION_DIRINCOVATION_DIR	TESTPATHSrI   rJ   rK   
ArgsSourcer    s5    	 tyy{"'DIIK	rJ   r  Nr   r   r   rP   c                t   ddl m} ddl m} |&| j                  dd t	        j
                               }t        j                         | _        	 || _	        	 |} |d| d| d| j                  d	
      | _        || _        	 t               | _        	 | j                  | _        | j                  j                   j"                  j%                  d      | _        t'        | j                  j(                        | _        i | _        d| _        i | _        g | _        | j                  j3                  | d       d| _        | j(                  j6                  j9                  t;        | j                  | j                               t<        j>                  j@                  | _!        g | _"        tF        rddl$m%} d | _&        y y )Nr   )FILE_OR_DIRr4   rI   r   z%(prog)s [options] [z] [z] [...]T)usage
processopt	_ispytestri   pytestconfigF)parserr   r1  r   )Cache)'
argparsingr  r5   r   r   r   argparse	Namespaceoptionr   _processopt_parserr   r0   stash_storer  r  rp   r    rr   	_inicache_override_ini	_opt2dest_cleanupr   r  pytest_addoptionr7  r8  r   r  r  args_sourcerd   r   _pytest.cacheproviderr  cache)rS   r   r   r  r5   _ar  s          rK   rT   zConfig.__init__
  s    	,&$ $ 5 5488: !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!	3*.DJ rJ   c                     | j                   S )znThe path to the :ref:`rootdir <rootdir>`.

        :type: pathlib.Path

        .. versionadded:: 6.1
        )	_rootpathrY   s    rK   rH  zConfig.rootpathL  s     ~~rJ   c                     | j                   S )zThe path to the :ref:`configfile <configfiles>`.

        :type: Optional[pathlib.Path]

        .. versionadded:: 6.1
        )_inipathrY   s    rK   inipathzConfig.inipathV  s     }}rJ   funcc                 :    | 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   )rS   r  s     rK   add_cleanupzConfig.add_cleanup`  s     	T"rJ   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defaultrh   r1  )r  r   catch_warningssimplefilterrr   rE  r7  r8  rY   s    rK   _do_configurezConfig._do_configuree  sl    ####$$& 	O!!),II&&44D<M4N	O 	O 	Os   AA99Bc                    | j                   r>d| _         | j                  j                  |        g | j                  j                  _        | j
                  r/| j
                  j                         } |        | j
                  r.y y )NFrh   )r  rr   pytest_unconfigurerE  _call_historyr  ru   )rS   fins     rK   rt   zConfig._ensure_unconfigurel  sa    $DII(((579DII&&4mm--##%CE mmrJ   c                 X    | j                   j                  d      }|J |j                  S )Nterminalreporter)r   r=  _tw)rS   r  s     rK   get_terminal_writerzConfig.get_terminal_writeru  s6    7;7I7I7T7T8
  +++###rJ   rd   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_helprx   r   r  )rS   r   rd   r  s       rK   r   zConfig.pytest_cmdline_parse|  s    	JJt& %  	 t{{Iu59L:D!  VU3x47G4SW<'')446

  Q !	s
    BB0excinfor  c                 z   |rt        |dd      rd}nd}|j                  dt        |dd      |      }| j                  j                  ||      }t	        |      s`t        |      j                  d	      D ]B  }t        j                  j                  d
|z         t        j                  j                          D y y )N	fulltraceFlongnativeT
showlocals)funcargsr  rl   )excreprr  rn   zINTERNALERROR> %s
)r   r}   rr   pytest_internalerroranyr\   r`   rx   ry   r  r   )rS   r  r  rl   r  resrz   s          rK   notify_exceptionzConfig.notify_exception  s    
 gfk59%+EE//gflE&JRW " 
 ii,,Wg,N3xG**40 #

  !6!=>

  "# rJ   nodeidc                     | j                   j                  | j                  k7  r/| j                  |z  }t        | j                   j                  |      }|S rR   )r   r   rH  r+   )rS   r  fullpaths      rK   cwd_relative_nodeidzConfig.cwd_relative_nodeid  sE    !!%%6}}v-H !7!7!;!;XFFrJ   c                     t        |      }|j                  j                  j                  |       |j	                  |d       |j                  j
                  D ]  }|j                  j                  |        |S )z$Constructor usable for subprocesses.Faddopts)r   r  __dict__updater	  re   r   r   )clsoption_dictrd   ri   r_  s        rK   fromdictargszConfig.fromdictargs  sh     D!%%k2T5)&& 	7A  33A6	7rJ   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  )rS   r  r   s      rK   r  zConfig._processopt  sp    OOcnn4 	,D#&88DNN4 	, 3	"4;;1SXXs{{; 2 #rJ   )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rd   rF  r+  rJ  rH  r4  rL  )rd   rF  rG  rH  rI  rJ  rK  rL  )_decide_argsknown_args_namespacefile_or_dirrF  getinir   r   rH  r   rW  rG  rI  rK  )rS   early_configrd   r  s       rK   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 	
rJ   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)inifilerd   rootdir_cmd_argrJ  rootdirr6  r  zExtra command line optionsrd   
minversionz!Minimally required pytest versionrequired_pluginsz.Plugins that must be present for pytest to run)rX   r  rI   )r  parse_known_and_unknown_argscopyr  r#   inifilenamer/  r8  r   r   r  r  inicfgr\   rH  
extra_infor  addinioverride_inir  )rS   rd   nsunknown_argsrH  r  r>  s          rK   _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rJ   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  r;  r   r  r   install_importhook_mark_plugins_for_rewriteSystemError_warn_about_missing_assertion)rS   rd   rB  rC  r  r   rr   s          rK   _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     rK   	<genexpr>z=Config._mark_plugins_for_rewrite.<locals>.<genexpr>.<genexpr>  s     Fb288z)Fs   N)r  entry_pointsfilesr\   )rS  distfiles      rK   rU  z3Config._mark_plugins_for_rewrite.<locals>.<genexpr>  sN      
FD4E4EFF

(b	
  I

s   AA)
r   r  ra   ro   rp   r_   metadatadistributionsr  r  )rS   rr   r  r   s       rK   rJ  z Config._mark_plugins_for_rewrite  sh     +/'::>>:;
!**88:
 -]; 	$Dd#	$rJ   viac                     || j                   _        	 | j                   j                  |t        j                  | j                               | j                   `|S # | j                   `w xY w)zValidate known args.r4  )r  _config_source_hintr;  r<  r  )rS   rd   r\  s      rK   _validate_argszConfig._validate_args  s[    +.(	1LL55		$++ 6 6  0 0s   :A A)rF  r+  rJ  rH  r4  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.r<   
stacklevel)r   r  r  r  extendsortedr^  iglobissue_config_time_warningr1   r  r\   )rS   rd   rF  r+  rJ  rH  r4  sourceresultrN   warning_texts              rK   r-  zConfig._decide_args(  s      &&++FF2 v~/ )**44&FF ) PfTZZ-M&NOP !\ )
 !:: 3L Aa ;  **99n-.v~rJ   r  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 configr4  Fr   rO  r  )r1  rd   r  z"could not load initial conftests: r;   rb  )#ra   ro   rp   r  r_  shlexr`   rD  r0  r  parse_known_argsr<  r  r.  _checkversionrM  r   r   r  r  _validate_plugins_warn_about_skipped_pluginsrI  r  r\   r   rH  rr   r2  rM   r  r  rg  r1   rN   )rS   rd   r  env_addoptsrI  r   s         rK   	_preparsezConfig._preparseU  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rR   )_validate_config_optionsrY   s    rK   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                  d| j                  z         ||       ||j                        kD  r.|j                  | j                   d| d|j                   d      y y )Nr   r9  Versionz'%s: 'minversion' must be a single valuez: 'minversion' requires pytest-z, actual pytest-')
r8   r>  rp   packaging.versionrz  r   r\   r"   r  r$   )rS   r8   minverrz  s       rK   ro  zConfig._checkversion  s    t41fc*''=L  v););!<<''||n$CF8K[\b\n\n[oopq  = rJ   c                 j    t        | j                               D ]  }| j                  d| d        y )NzUnknown config option: rn   )re  _get_unknown_ini_keys_warn_or_fail_if_strict)rS   keys     rK   rv  zConfig._validate_config_options  s9    $4467 	LC((+B3%r)JK	LrJ   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)
Nr:  r   )InvalidRequirement)Requirementry  T)prereleaseszMissing required plugins: {}r   )re  r0  packaging.requirementsr  r  r|  rz  r   list_plugin_distinfoproject_namer  r   r   	specifiercontainsr"   r   r   )rS   r:  r  r  rz  plugin_infor-  rX  plugin_dist_infomissing_pluginsrequired_pluginreqs               rK   rp  zConfig._validate_plugins  s4   !$++.@"AB 	>6-((==?KVW4D--t||;WW/ 	8O!/2
 xx//&&7]]++(23 ,   &&7	8 .55dii6PQ  # X & &&7s   !D;DD21D2r   c                 ~    | j                   j                  rt        |      | j                  t	        |      d       y )Nr<   rb  )r.  strict_configr"   rg  r1   )rS   r   s     rK   r  zConfig._warn_or_fail_if_strict  s6    $$22W%%&&':7'CPQ&RrJ   c                 v    | j                   j                  }| j                  D cg c]	  }||vs| c}S c c}w rR   )r  _inidictr>  )rS   parser_inicfgr   s      rK   r  zConfig._get_unknown_ini_keys  s0    --!%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   r1  r  Tr4  r+  r,  )rd   rr   pytest_addhooksr7  r8  r   rs  r  after_preparseparse_setoptionr  r-  r.  rF  r0  r   r   rH  r  r!   )rS   rd   r  s      rK   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warningrc  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alwaysrb  r   r   ri   r  )warning_messagewhenr  locationr1  )r   r  r.  pythonwarningsr0  r   r  r  rX   apply_warning_filtersr4  rx   	_getframef_codeco_filenamef_linenoco_namerr   pytest_warning_recordedr7  r8  )rS   r  rc  cmdline_filtersconfig_filtersrecordsframer  s           rK   rg  z Config.issue_config_time_warning  s    ((433BBHb%56$$D1 	:W!!(DM:!./BMM'j9	:
 MM*q.1E||//AUAUUHII--;;$+AJ!%	 <  	: 	:s   AD22D;r   rz   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)r0  r   r   r   )rS   r   rz   r_  s       rK   rD  zConfig.addinivalue_line  s-     KK!T"""	rJ   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)rS   r   vals      rK   r0  zConfig.getini  sF    8	>>$'' 	)-d);;DNN4 3J	s    +??rX   valuec                 $    d| }t        ||      )Nzunknown configuration type: )rv   )rS   r   rX   r  r   s        rK   _getini_unknown_typezConfig._getini_unknown_type=  s    ,TF3e$$rJ   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: pathsrd   linelistc                 "    | j                         S rR   r  )r_  s    rK   <lambda>z Config._getini.<locals>.<lambda>i  s     rJ   rn   r@  string)r  r  rj  rv   _get_override_ini_valuer>  r  r   r   r   r   r\   rm  r`   map
_strtoboolr  r  )rS   r   descriptionrX   r  r   override_valuer  dpinput_valuesr_  ts               rK   r  zConfig._getiniA  s   	N)-)>)>t)D&Kw 55d;!D) #E  7? <<+ ##++// 
 2<E31G5;;u-UL$01qBF11V^)3E3)?5;;u%JUJZ%%#&':EKK<M#NTaRS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rN   c                    	 | j                   j                  ||      \  }}|j                  J t	        |j                        j
                  }g }|D ]g  }t        |t        j                        rt	        |      }n.|j                  dt        j                        }t        ||z        }|j                  |       i |S # t        $ r Y y w xY w)Nr  )r   rl  rj  ru  r   r   r   ra   r   r5  rb   r*   r   )rS   r   rN   rf  relrootsmodpathvaluesrelroots           rK   _getconftest_pathlistzConfig._getconftest_pathlistu  s    	 ..AA$MMC ||'''s||$++ 	#G'2;;/w-!//#rvv6&w'89MM'"	#   		s   B> >	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`   rv   r"   )rS   r   r  
ini_configr  user_ini_valuer   s          rK   r  zConfig._get_override_ini_value  s~     ,, 		+J+&0&6&6sA&>#^ $;*E		+    I*WYZs   4	AAAFskipc                    | 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)ai  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: Default value if no option of that name exists.
        :param skip: If True, raise pytest.skip if option does not exists
            or has a None value.
        Nr   zno z option foundzno option named )	r  rp   r   r  r   notsetr8   r  rv   )rS   r   r  r  r  r   r8   s          rK   	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  rS   r   rN   s      rK   getvaluezConfig.getvalue  s    ~~d##rJ   c                 (    | j                  |d      S )z-Deprecated, use getoption(skip=True) instead.T)r  r  r  s      rK   getvalueorskipzConfig.getvalueorskip  s    ~~d~..rJ   
assertionsVERBOSITY_ASSERTIONS
test_casesVERBOSITY_TEST_CASESr  _VERBOSITY_INI_DEFAULTverbosity_typec                    | j                   j                  }t        |t              sJ ||S t        j                  |      }|| j                  j                  vr|S | j                  |      }|t        j                  k(  r|S t        |      S )a4  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
        )
r  verboser   intr   _verbosity_ini_namer  r  r0  r  )rS   r  global_levelini_namelevels        rK   get_verbosityzConfig.get_verbosity  s    < {{**,,,,!--n=4<<000H%F1115zrJ   c                     d|  S )N
verbosity_rI   )r  s    rK   r  zConfig._verbosity_ini_name  s    N+,,rJ   r  r5   r  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  rX   r  N)r@  r   r  r  )r  r  r  s      rK   _add_verbosity_inizConfig._add_verbosity_ini  s2     	&&~611	 	 	
rJ   r  c                 f    t               s'|dk(  rd}nd}| j                  t        |      d       y y )NrG  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?)
r<   rb  )_assertion_supportedrg  r1   )rS   r  rj  s      rK   rL  z$Config._warn_about_missing_assertion   sH    #%w( 3  **#L1 +  &rJ   c           	          | j                   j                  D ]'  \  }}| j                  t        d|d|       d       ) y )Nzskipped plugin rV   r;   rb  )r   r  rg  r1   )rS   r  r   s      rK   rq  z"Config._warn_about_skipped_plugins  sM     $ 2 2 B B 	K**#ok_Bse$LM + 	rJ   r  rR   )rP   r   )r  r3   rP   N)r1  r   rP   N)T)Qr?   r@   rA   rB   r   dataclasses	dataclassr   r  Enumr  r   r   rT   propertyr   rH  r  r   r  r  rt   r'   r  r   r\   r   r%   r   r  r  r  r  classmethodr$  r  hookimplr2  r   rD  rM  rJ  r_  r@  r   r-  rs  r   r  rw  ro  rv  rp  r  r  r	  Warningr  rg  rD  r0  r   r  r  r  r  r  r  r  r  r  r   r  r  r  r  r   r  r  rL  rq  rI   rJ   rK   r   r     sg    [$'1 1 ( 1B TYY  $ 9=	@/*@/ $$45	@/
 
@/D $   $  #T 2 #t #
O$^ $08<S		8 04#}-# ++,# 
	#$# #   < d
 
43Xc] 3t 321# 14 1($(
49 
3 
49 
+ 3i+ 	+
 9+ + + + 
tCy*$	%+Z4d3i 4$ 4$ 4l d,9T66-A#B , ,$LBSs St SKtCy K$s) d d 2! !c !d !FS    3  H% %C %c4PS9n@U %2@C 2@h# T htDz>R "C HSM " ,2 Ac A A0$S $/3 /
 #/%.".%.$*E*+HSM +S +Z -C -C - - 
8 
S 
 
PT 
 
"# $ *rJ   c                  &    	 J # t         $ r Y yw xY w)NT)rt  rI   rJ   rK   r  r    s    u s    	ri   rY  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.
    )rY  yesTnoF)r'   r  color	hasmarkupcode_highlight)ri   rY  r   s      rK   create_terminal_writerr  &  s     
T	"B}}e#				$}}##u,  I 
	%	%	-!IrJ   r  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 )lowerrv   )r  s    rK   r  r  >  s:     ))+C
22	5	5/w788rJ   2   )maxsizer  escapezwarnings._ActionKindc          	         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}
        :r>   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rR   r  )rS  ss     rK   rU  z'parse_warning_filter.<locals>.<genexpr>{  s     3M!AGGI3Ms   Nr  )rl   z\Zr   znumber is negativezinvalid lineno rV   )r   r`   r  r"   r   r   r   
_getaction_OptionErrorr\   _resolve_warning_categoryr[   r%   from_currentr}   rer  r  rv   )r  r  __tracebackhide__error_templater  doc_urlr	  action_r   	category_modulelineno_actionr   categoryr   exception_textlinenos                     rK   parse_warning_filterr  P  s*     % 		
N IIcNE
5zA~X 	 !%j\ *2 3: ;
 ..U.;<<
e*q.R e*q.3Mu3M0GWiH)1)<)<W)E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$r  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          rK   r  r    s    
 
(#..s35vtTE73
!U
Cc7#C5 :;<<Ws##rJ   r  r  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      rK   r  r    sT      J!5c%!HIJ  I!5c$!GHIrJ   )NN)rP   r   rR   )rB   r  collections.abcr  r<  r  r  	functoolsr   r^  importlib.metadatar_   r   ra   pathlibr   r  rm  rx   textwrapr   r9  r   typingr   r   r	   r
   r   r   r   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._ior'   _pytest.deprecated_pytest.hookspec_pytest.outcomesr(   r)   _pytest.pathlibr*   r+   r,   r-   r.   r/   _pytest.stashr0   _pytest.warning_typesr1   r2   r  r3   r5   _pytest._code.coder6   _pytest.terminalr7   r  r  r  r  IntEnumr:   r[   rM   _codeTracebackEntryr@  rc   r\   r  r   r   r   r   r   r  r   r	  r  rr  r   r   rq   r   r   r   r:  r  r  r  r  r   r  r  r  r  r  r  r  rI   rJ   rK   <module>r<     s   @          	  	  
                          !  !    & . 0 &   ' * &   ! $ ( ' ' & 0 '  5 3 $"21  (#(# t||  ,OI OX==''X	X <@=A6>
5c$667
86>huS-%789:6> 3=6>rc $ s S S  c c    	
             !" #$ %& '( )* +, -. /0 12 34 56 7< o&   J    ) * !%=A
49
huS-%789: 2& <@=A
5c$667
8huS-%789: @ $  S#X 
#t)_	@ _(- _( _(Du''hsm;<	#Y, 
 
>CHSM >Chsm >CB L L L^d  .2"6*09C 9D 9$ 2D5	D5D5
!3WsC?@D5 D5N$ $W $,
ISM
I4<SM
I	
IrJ   