
    Bh                   X   d 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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&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d/lQmRZR dd0lSmTZT dd1lUmVZV eWZX	  e(d2      ZY e*d2      ZZe" G d3 d4ej                               Z\ G d5 d6e]      Z^	 	 	 	 dod7Z_	 	 dp	 	 	 	 	 dqd8Z`drd9Za G d: d;      Zbdsd<Zcdsd=Zdd>Zeg ee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Zfh efdXdYZg	 	 dp	 	 	 	 	 dtd[Zhdud]Zi	 	 dp	 	 	 	 	 dvd^Zjdwd_Zk	 	 	 	 	 	 	 	 dxd`Zle" G da d\e,             Zm	 	 	 	 dydbZn G dc dd      Zo eo       ZpdzdeZqe" G df dZ             Zrd{dgZs	 d|	 	 	 	 	 d}dhZtd~diZu edjk      	 	 	 	 	 	 ddl       ZvddmZw	 	 	 	 	 	 ddnZxy)z:Command line options, ini-file and conftest.py processing.    )annotationsN)Callable)	Generator)Iterable)Iterator)Sequence)	lru_cache)dedent)FunctionType)Any)cast)Final)final)IO)TextIO)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)AssertionRewritingHook)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     b/var/www/html/Telegram-Engagement-Pod-/env/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unraisableexceptionthreadexceptionwarningsloggingreports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   4  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<   r/   r   r   )method	hook_type	opt_namesmknown_marks	must_warnoptsopt_nameopt_attrr   messages              rF   _get_legacy_hook_marksr   g  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 m} ddl m} t        |   d       t               | _        i | _        d | _        d| _	         t        d      t              | _        g | _        | j                  t        j                         | j!                  |        t"        j$                  j'                  d      rt(        j*                  }t-        |dd	      }	 t/        t#        j0                  |j3                               |j4                  d
|      }| j8                  j:                  j=                  |j>                         | jA                           |       | _!        d| _"        y # t6        $ r Y ^w xY w)Nr   )DummyRewriteHook)RewriteHookr3   F   PYTEST_DEBUGencodingutf8r   )mode	bufferingr  )#_pytest.assertionr   r   superrN   set_conftest_plugins_dirpath2confmods_confcutdir_noconftestr	   r   skipped_pluginsadd_hookspecsr   hookspecr   r]   rj   rk   rs   rt   r   r   dupr   r  rV   traceroot	setwriterwriteenable_tracingrewrite_hook_configured)rM   r   r   errr  	__class__s        rF   rN   zPytestPluginManager.__init__  s#   61" 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      }t        t        |      S ):meta private:pytest_Npytest_pluginsimpl)tryfirsttrylastoptionalhookhookwrapper)	
startswithr  parse_hookimpl_optsr   r   r   r   r   r   )rM   r   r   r   r   legacyr  s         rF   r%  z'PytestPluginManager.parse_hookimpl_opts  sz     y)##w*648K&  ('FR
 L&))rE   c                    t         |   ||      }|:t        ||      }|j                  d      rt	        |dd      }t        t        |      }|S )r  r  r   )firstresulthistoric)r  parse_hookspec_optsr   r$  r   r   r   )rM   module_or_classr   r   r   r&  r  s         rF   r*  z'PytestPluginManager.parse_hookspec_opts  sV    w*?DA<_d3Fy)/F$? L&1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
importmoderJ  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_confcutdirV  s*    # 4++3333rE   c                   | j                  ||||       |j                         r=|j                  d      D ](  }|j                         s| j                  ||||       * y y )NrI  ztest*)_loadconftestmodulesis_dirglob)rM   rW  rS  rP  rJ  xs         rF   rM  z&PytestPluginManager._try_load_confteste  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.pyrI  )	r  r   r  reversedrZ  r\  r   _importconftestr   )
rM   rK   rS  rP  rJ  	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   re  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   )rj  rc  r   r   KeyError)rM   r   rK   modulesrh  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  rJ  )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   r9  r:  r+   rs   rm  stemrl  r)   rV   __traceback__rH   _check_non_top_pytest_pluginsr
  addr   r  itemsrZ  AssertionError__file__r   r  consider_conftest)rM   rg  rS  rP  rJ  conftestpath_plugin_nameexistingpkgpathrh  r   dirpathrK   modss                rF   rd  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  rK  r%   r   r  )rM   rh  rg  r   s       rF   rs  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   rV  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   conftestmodulerp  s      rF   rx  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_env4  s    !!"**..1A"BCrE   c                <    | j                  t        |dg              y)r  r  N)r  r   )rM   rh  s     rF   r;  z#PytestPluginManager.consider_module8  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   rm  r   ImportErrorr|   with_tracebackrr  r&   r  r   r   )rM   modnamer  
importspecloadedrh  r   s          rF   r   z!PytestPluginManager.import_pluginC  s,    '3' 	
0<	
' ??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]rN  r@  rO  r@  rP  rU   rQ  pathlib.Path | NonerR  rU   rS  zImportMode | strrJ  r@  rW   rX   )rK   rU   rW   r@  )
rW  rU   rS  str | ImportModerP  rU   rJ  r@  rW   rX   )
rK   rU   rS  r  rP  rU   rJ  r@  rW   rX   )rK   rU   rW   zSequence[types.ModuleType])r   rY   rK   rU   rW   ztuple[types.ModuleType, Any])
rg  rU   rS  r  rP  rU   rJ  r@  rW   types.ModuleType)rh  r  rg  rU   rW   rX   )r|   Sequence[str]r   r@  rW   rX   )r  rY   rW   rX   )r  r  rp  rY   rW   rX   )rh  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>  rA  rE  rX  r\  rM  r^  rj  rn  rd  rs  r   r   rx  r  r;  r  r   __classcell__)r  s   @rF   r   r     s   2!h*#*+.*	*6
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   r9  r:  rY   r\   collectionsabcr   r   r   )specss    rF   r  r  i  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	 	 	 	 	 dAdZedBd       ZedCd       ZdDdZdEdZdEdZdFdZ	 	 	 	 	 	 dGdZ	 dH	 	 	 	 	 dIdZdJdZedKd       ZdLdZ ed      dMd       ZdNdZdNdZ	 	 	 	 	 	 dOdZdEdZdEdZ dPdZ!	 	 	 	 	 	 	 	 	 	 	 	 	 	 dQd Z"dRdSd!Z# ed"      dTd#       Z$dEd$Z%dEd%Z&dEd&Z'dUd'Z(dVd(Z)dRdSd)Z*dWd*Z+dXd+Z,dYd,Z-dZd-Z.d[d.Z/	 	 	 	 	 	 d\d/Z0d]d0Z1e2d1fd^d2Z3dHd[d3Z4dHd[d4Z5d5Z6d6ed7<   d8Z7d6ed9<   d:Z8d6ed;<   dHd_d<Z9e:d`d=       Z;e:dad>       Z<dbd?Z=dEd@Z>y
)cr   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 | _        t3        j4                         | _        | j                  j9                  | d       d| _        | j*                  j<                  j?                  tA        | j                  | j                               tB        jD                  jF                  | _$        g | _%        y )Nr   )FILE_OR_DIRr#   rD   r   z%(prog)s [options] [z] [z] [...]T)usage
processopt	_ispytestrd   pytestconfigF)parserr   r1  )&
argparsingr  r$   r   r   r   r   argparse	Namespaceoptionr   _processopt_parserr   r-   stash_storer  r  rk   r   rm   	_inicache_override_ini	_opt2dest
contextlib	ExitStack_cleanup_stackr   r  pytest_addoptionr7  r8  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	)+,.)+(224##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   rP  zConfig.rootpathD  s     ~~rE   c                    | j                   S )zXThe path to the :ref:`configfile <configfiles>`.

        .. versionadded:: 6.1
        )_inipathrS   s    rF   inipathzConfig.inipathN  s     }}rE   c                :    | j                   j                  |       y)zAdd a function to be called when the config object gets out of
        use (usually coinciding with pytest_unconfigure).
        N)r  callback)rM   funcs     rF   add_cleanupzConfig.add_cleanupV  s     	$$T*rE   c                    | j                   rJ d| _         | j                  j                  j                  t	        |              y )NTrc   r1  )r  rm   rE  r7  r8  rS   s    rF   _do_configurezConfig._do_configure\  s9    ####		""00D8I0JrE   c                .   	 | j                   r?d| _         	 | j                  j                  |        g | j                  j                  _        	 | j
                  j                          t        j                         | _        y # g | j                  j                  _        w xY w# t        j                         | _        w xY w# 	 | j
                  j                          t        j                         | _        w # t        j                         | _        w xY wxY w)NFrc   )	r  rm   pytest_unconfigurerE  _call_historyr  closer  r  rS   s    rF   ro   zConfig._ensure_unconfigurea  s    	=#( BII000=?ADII..<=##))+&0&:&:&<# @BDII..<
 '1&:&:&<#=##))+&0&:&:&<#j&:&:&<#sE   C  B C  B" BC  "B= DC6D6DDc                X    | j                   j                  d      }|J |j                  S )Nterminalreporter)r   r=  _tw)rM   r  s     rF   get_terminal_writerzConfig.get_terminal_writero  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_parsev  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 )NrG  )r   r   rP  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   ra  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 )Ndefault)_short_opts
_long_optsdestr  r  r  setattrr3  )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|   rN  r9  rR  rP  r4  rJ  )r|   rN  rO  rP  rQ  rR  rS  rJ  )_decide_argsknown_args_namespacefile_or_dirrN  getinir   r   rP  r   rX  rO  rQ  rS  )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                   j#                  dddg        |j$                  xs d| _        y )N	namespace)inifiler|   rootdir_cmd_argrR  rootdirrD  r,  zExtra command line optionsr|   
minversionz!Minimally required pytest version
pythonpathpathszAdd paths to sys.path)rR   r  r3  required_pluginsz.Plugins that must be present for pytest to run)rR   r3  rD   )r  parse_known_and_unknown_argscopyr  r   inifilenamer=  rF  r   r   r  r  inicfgrY   rP  
extra_infor   addinioverride_inir  )rM   r|   nsunknown_argsrP  r   rN  s          rF   _initinizConfig._initini  sJ   <<DDDIIdkk2 E 
L %4NN,.JJ.$1155	%
!'6 "-0-?	*-0->	*I'CVLL*MNw-Db 	 	
 	<	 	 	
  __2rE   c                z   | j                   j                  |      \  }}t        |dd      }t        |dd      xs( t        t        j
                  j                  d            }|dk(  r2d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disable_plugin_autoloadFPYTEST_DISABLE_PLUGIN_AUTOLOADrewriter   N)r  rK  r   r@  r]   rj   rk   r  r   install_importhook_mark_plugins_for_rewriteSystemError_warn_about_missing_assertion)rM   r|   rR  rS  r  disable_autoloadr   rm   s           rF   _consider_importhookzConfig._consider_importhook  s      <<DDTJLr<1"2'@%H 
DJJNN;<M
 9$G((;;DA ..t5EF**40	  s   -B, ,B:9B:c                    || j                   _        |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.Nc              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   )re  distfiles      rF   rg  z3Config._mark_plugins_for_rewrite.<locals>.<genexpr>  sK      
:FD4E4EFF

(b( I ) :s   AA)r   r  r[   metadatadistributionsr  r  )rM   rm   r_  r  r   s        rF   r\  z Config._mark_plugins_for_rewrite  sW     +/' 
!**88:
 -];Dd# <rE   c                    t        | j                  d            D ]+  }t        j                  j	                  dt        |             - | j                  | j                         y )NrH  r   )rc  r>  rs   rK   insertrY   r  _unconfigure_python_pathr[  s     rF   _configure_python_pathzConfig._configure_python_path$  sD    T[[67DHHOOAs4y) 8667rE   c                    | j                  d      D ]?  }t        |      }|t        j                  v s!t        j                  j	                  |       A y )NrH  )r>  rY   rs   rK   remove)rM   rK   path_strs      rF   rp  zConfig._unconfigure_python_path*  s:    KK-D4yH388#) .rE   c                    || j                   _        	 | j                   j                  |t        j                  | j                               | j                   `|S # | j                   `w xY w)zValidate known args.rB  )r  _config_source_hintrK  rL  r  )rM   r|   vias      rF   _validate_argszConfig._validate_args0  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|   rN  r9  rR  rP  r4  sourceresultrK   warning_texts              rF   r;  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"                  j%                  |d       t         j                  j                  d	      s1| j                  j&                  s| j"                  j)                  d
       | j"                  j+                          | j                  j                  |t        j                  | j                              | _        | j-                          | j/                          | j                  j0                  R| j2                   t5        | j2                  j6                        }nt5        | j8                        }|| j                  _        	 | j:                  j=                  | || j                         y # t>        $ ra}| j                  j@                  s| j                  jB                  r*| jE                  tG        d|jH                         d       n Y d }~y d }~ww xY w)NPYTEST_ADDOPTSr  zvia PYTEST_ADDOPTSr,  zvia addopts configrB  Fr   rY  r  )r?  r|   r  z"could not load initial conftests: r6   r{  )%r]   rj   rk   r  rx  shlexr\   rT  r>  r  parse_known_argsrL  r  r<  _checkversionr`  rq  r   r   rX  r  r  _validate_plugins_warn_about_skipped_pluginsrQ  r   rY   r   rP  rm   r@  rH   r  r  r  r.   rK   )rM   r|   r,  env_addoptsrQ  r   s         rF   	_preparsezConfig._preparsei  sf   **..)92>K;''K(@BVW Q 	d##DKK	$:<PQTXX G %)LL$A$ADIIdkk2 %B %
! 	!!$'##%,,T,F

?@--EE :::F 	'')$(LL$A$ADIId&?&?@ %B %
! 	 ((*$$//7||' !4!45
 /
3=D%%0	II33!T\\ 4  % 		((--1J1J1R1R ..'*LQVVH(UV  / 
 			s   (I; ;	K%AK  K%)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   rG  Versionz%: 'minversion' must be a single valuez: 'minversion' requires pytest-z, actual pytest-')
r3   rN  rk   packaging.versionr  r   rY   r   r   r   )rM   r3   minverr  s       rF   r  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   )r~  _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)
NrJ  r   )InvalidRequirement)Requirementr  T)prereleaseszMissing required plugins: {}r   )r~  r>  packaging.requirementsr  r  r  r  r   list_plugin_distinfoproject_namer  r   r   	specifiercontainsr   r   r   )rM   rJ  r  r  r  plugin_infor-  rj  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   r{  )r<  strict_configr   r  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  _inidictrN  )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   r1  r+  TrB  r9  r:  )r|   rm   pytest_addhooksr7  r8  r   r  r  after_preparseparse_setoptionr  r;  r<  rN  r>  r   r   rP  r  r   )rM   r|   r,  s      rF   r  zConfig.parse  s    yyB 	
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alwaysr{  r   r   rd   r  )warning_messagewhenr$  locationr1  )r   r  r<  pythonwarningsr>  r   catch_warningssimplefilterrR   apply_warning_filtersr4  rs   	_getframef_codeco_filenamef_linenoco_namerm   pytest_warning_recordedr7  r8  )rM   warningr|  cmdline_filtersconfig_filtersrecordsframer  s           rF   r  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   ra  s       rF   rD  zConfig.addinivalue_line+  s-     KK!T"""	rE   c                    	 | j                   |   S # t        $ r% | j                  |      x| j                   |<   }|cY S w xY w)al  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 ``""``
        ``int`` : ``0``
        ``float`` : ``0.0``

        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  rl  _getini)rM   r   vals      rF   r>  zConfig.getini3  sF    <	>>$'' 	)-d);;DNN4 3J	s    +??c                .    d| d| d|}t        |      )NzOption z  has unknown configuration type z with value )rq   )rM   r   rR   valuer   s        rF   _getini_unknown_typezConfig._getini_unknown_typeY  s*    dV;D6eYW 	 orE   c                    	 | 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 |d	k(  r-t        |t              st#        d
| d|      d t%        |      S |dk(  r-t        |t              st#        d| d|      d t'        |      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: rI  r|   linelistc                "    | j                         S rJ   r  )ra  s    rF   <lambda>z Config._getini.<locals>.<lambda>  s
    rE   ri   r@  stringintz"Expected an int string for option z of type integer, but got: floatz#Expected a float string for option z of type float, but got: )r  r  rl  rq   _get_override_ini_valuerN  r   r   r   r   r   rY   r  r\   map
_strtoboolr  r   r  r  r  )rM   r   descriptionrR   r3  r   override_valuer  dpinput_valuesra  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U]eS)8>YZ_Ybc u:W_eS)9$?XY^Xab <\L,,T4??w  	N<THEFAM	N  4 2
 Us:   G G5 -HH#H	G2G--G25HH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   rn  rl  rw  r   r   r   r   r]   r   r5  r^   r'   r   )rM   r   rK   rh  relrootsmodpathvaluesrelroots           rF   _getconftest_pathlistzConfig._getconftest_pathlist  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   r3  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   )r3  )	r  r   r  r   _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   r3  N)rP  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 )NrW  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   r{  )_assertion_supportedr  r.   )rM   r  r  s      rF   r^  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   r{  )r   r  r  r.   )rM   r  r   s      rF   r  z"Config._warn_about_skipped_pluginsC  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   )rm   r0   r_  r@  rW   rX   )r|   r  rw  rY   rW   r  )r|   r  rN  r@  r9  r  rR  rU   rP  rU   r4  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  Warningr|  r  rW   rX   )r   rY   ru   rY   rW   rX   )r   rY   rW   r   )r   rY   rR   rY   r  r  r  )r   rY   rK   rU   rW   zlist[pathlib.Path] | None)r   rY   rW   r  )r   rY   r3  r   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   propertyrP  r   r  r  ro   r  r   r"  r)  classmethodr1  r  hookimplr@  rT  r`  r\  rq  rp  rx  r;  r  r  r  r  r  r  r  r  r  rD  r>  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r^  r  rD   rE   rF   r   r     s    [$'1 1 ( 1B TYY   L 6:	;"*;" 3	;"
 
;"z    +K
=$08A	8 -1#-# *# 
	#$	  < d
 
43810$*$>B$	$.8*
+ + 	+
 + %+ + + 
&+Z:x d, ,$LBSK2!F"L>@@+	"&" 39u A2$/
 #/%.".%.$*E*,\ - - 
 
"*rE   c                 &    	 J # t         $ r Y yw xY w)NT)rv  rD   rE   rF   r  r  K  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.
    )rk  yesTnoF)r!   r  color	hasmarkupcode_highlight)rd   rk  r   s      rF   create_terminal_writerr  T  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  l  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}	 t        j&                  |       t        j&                  |
       ||||
|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# t        j(                  $ r1}t        |j	                  d|j*                  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  )re  ss     rF   rg  z'parse_warning_filter.<locals>.<genexpr>  s     3Mu!AGGIus   Nr  )rg   z\Zr   znumber is negativezinvalid lineno rP   zInvalid regex )r
   r\   r  r   r   r   r   
_getaction_OptionErrorrY   _resolve_warning_categoryrV   r   from_currentrx   reescaper  rq   compiler$  pattern)r  r,  __tracebackhide__error_templater  doc_urlr$  action_r   	category_modulelineno_actionr   categoryr   exception_textlinenos                     rF   parse_warning_filterr:  ~  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  


7


6
 7Hff44=    H..SV.<=4GH  P --/!)))9..^.DE4OP  	%%og[1#,N%O	 88 !!.Rs(K!L
	sU   'E =F  G *H F#%FFAG	H("H

HI%,II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   rR   )r7  r/  r   klassr4  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|   rC  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   rk  zTextIO | NonerW   r!   )r  rY   rW   r@  )r  rY   r,  r@  rW   z9tuple[warnings._ActionKind, str, type[Warning], str, int])r7  rY   rW   ztype[Warning])r  r  r  r  rW   rX   )yr=   
__future__r   r  collections.abcr  r   r   r   r   r   r  rL  r  r  	functoolsr	   r`  importlib.metadatar[   r   r]   r   r+  r  rs   textwrapr
   r9  r   typingr   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.   r/   _pytest.assertion.rewriter0   _pytest.cacheproviderr1   _pytest.terminalr2   r  r  r  r  IntEnumr5   rV   rH   r`   r   r   r   r   r   r  r   r  r   r   rl   r   r   r   r  r  r  r  r   r  r  r  r:  r)  r  rD   rE   rF   <module>r\     s    @ "   $ % $ $ $         	  	  
              !  !    & . 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:  "48
1 2& 1548
-1 @  	@ ^(- ^( ^(B8* 
 
>CB @ @ @F +/'09$ 2K5	K5K5>K5 K5\$,
I!
I4A
I	
IrE   