o
    v&i1                    @  s  d 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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/m0Z0 ddl1m2Z2 ddl1m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8Z6ddl8m9Z9 dd l8m:Z: dd!l;m<Z< dd"l=m>Z> dd#l?m@Z@ dd$lAmBZB dd%lAmCZC dd&lAmDZD ddlEZ6ddlFZ6dd'lGmHZH dd(lGmIZI dd)lJmKZK dd*lJmLZL dd+lJmMZM dd,lJmNZN dd-lJmOZO dd.lJmPZP dd/lQmRZR dd0lSmTZT dd1lSmUZU e'rdd2lVmWZW dd3lXmYZY dd4lZm[Z[ e\Z]	 e*d5Z^e,d5Z_e$G d6d7 d7ej`ZaG d8d9 d9ebZcdd>d?ZdddDdEZeddGdHZf		dddNdOZgddQdRZhG dSdT dTZiddXdYZjddZd[Zkd\Zlg eld]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtduR Zmh emdvdwZn		dddzd{Zodd}d~Zp	ddddZqdddZrdddZse$G dd| d|e.ZtdddZuG dd dZvev ZwdddZxe$G ddy dyZydddZz	ddddZ{dddZ|edddddZ}dddZ~dddZdS )z=Command line options, config-file and conftest.py processing.    )annotationsN)Callable)	Generator)Iterable)Iterator)Mapping)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)assert_never)Argument)FILE_OR_DIR)Parser)fail)Skipped)absolutepath)bestrelpath)import_path)
ImportMode)resolve_package_path)safe_exists)Stash)PytestConfigWarning)warn_explicit_for)AssertionRewritingHook)Cache)TerminalReporterpytestc                   @  s,   e Zd ZdZdZdZdZdZdZdZ	dZd	S )
ExitCodezEncodes the valid exit codes by pytest.

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

    .. versionadded:: 5.0
    r   r               r4   N)
__name__
__module____qualname____doc__OKTESTS_FAILEDINTERRUPTEDINTERNAL_ERRORUSAGE_ERRORNO_TESTS_COLLECTED rD   rD   ]/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/_pytest/config/__init__.pyr5   _   s    r5   c                   @  s    e Zd ZdddZdd
dZdS )ConftestImportFailurepathpathlib.Pathcause	ExceptionreturnNonec                C  s   || _ || _d S N)rG   rI   )selfrG   rI   rD   rD   rE   __init__y   s   
zConftestImportFailure.__init__strc                 C  s"   t | jj d| j d| j dS )N: z (from ))typerI   r:   rG   rN   rD   rD   rE   __str__   s   "zConftestImportFailure.__str__N)rG   rH   rI   rJ   rK   rL   )rK   rP   )r:   r;   r<   rO   rU   rD   rD   rD   rE   rF   x   s    
	rF   entry_pytest._code.TracebackEntryrK   boolc                 C  s   t | odt| 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   rP   rG   splitossep)rV   rD   rD   rE   ,filter_traceback_for_conftest_import_failure   s   r]   efiler   rL   c                 C  s   t | j}t|}|jd| j ddd |jt|_|jr'|j	dddn|
 }t|}| D ]}|j| dd q3d S )Nz$ImportError while loading conftest 'z'.TredshortF)stylechain)r   from_exceptionrI   r!   linerG   	tracebackfilterr]   getreprexconlyrP   
splitlinesrstrip)r^   r_   exc_infotwexc_reprformatted_tbrf   rD   rD   rE   print_conftest_import_error   s   rq   r   c                 C  s.   t |}| jD ]}|jd| ddd qd S )NzERROR: 
Tr`   )r!   argsrf   )r^   r_   rn   msgrD   rD   rE   print_usage_error   s   
ru   rs   #list[str] | os.PathLike[str] | Noneplugins$Sequence[str | _PluggyPlugin] | Noneint | ExitCodec              
   C  s  | du rt jdd n| }t|tr&|ddkr&t jdt d tj	S t
jd}zztt
jd< zt||}W n/ tyi } z#t|t jd tjW  Y d}~W W |du r_t
jdd S |t
jd< S d}~ww zH|jj|d}zt|W W |  W W |du rt
jdd S |t
jd< S  ty   | Y W |  W W |du rt
jdd S |t
jd< S w |  w  ty } z"t|t jd tjW  Y d}~W |du rt
jdd S |t
jd< S d}~ww |du rt
jdd w |t
jd< 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.
    Nr   	--versionzpytest rr   PYTEST_VERSIONr_   config)sysargv
isinstancer   countstdoutwriter   r5   r>   r[   environget_prepareconfigrF   rq   stderrrB   pophookpytest_cmdline_main_ensure_unconfigure
ValueErrorr   ru   )rs   rw   new_argsold_pytest_versionr~   r^   retrD   rD   rE   main   sX   


r   intc                  C  sN   zt  } tj  | W S  ty&   ttjtj}t	|tj
  Y dS w )zoThe CLI entry point of pytest.

    This function is not meant for programmable use; use `main()` instead.
    r   )r   r   r   flushBrokenPipeErrorr[   opendevnullO_WRONLYdup2fileno)coder   rD   rD   rE   console_main   s   
r   c                   @  s   e Zd ZeeZdS )cmdlineN)r:   r;   r<   staticmethodr   rD   rD   rD   rE   r          r   rG   rP   optnamec                 C  s"   t j| rt| d|  | S )ztArgparse type validator for filename arguments.

    :path: Path of filename.
    :optname: Name of the option.
    z must be a filename, given: r[   rG   isdirr   rG   r   rD   rD   rE   filename_arg      r   c                 C  s"   t j| st| d|  | S )zvArgparse type validator for directory arguments.

    :path: Path of directory.
    :optname: Name of the option.
    z must be a directory, given: r   r   rD   rD   rE   directory_arg   r   r   )markr   runnerfixtures
helpconfigpythonterminal	debuggingunittestcaptureskipping
legacypathtmpdirmonkeypatchrecwarnpastebin	assertionjunitxmldoctestcacheprovider	setuponly	setupplanstepwiseunraisableexceptionthreadexceptionwarningsloggingreportsfaulthandlersubtestspytesterpytester_assertionsIterable[str] | NoneConfigc                 C  sZ   t  }tj| pd|tj d}t||d}|jr!|j|jdd tD ]}|	| q#|S )NrD   rs   rw   dirinvocation_paramsTexclude_only)
PytestPluginManagerr   InvocationParamspathlibPathcwdrs   consider_preparsedefault_pluginsimport_plugin)rs   rw   pluginmanagerr   r~   specrD   rD   rE   
get_config/  s   r   r   c                   C  s   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   rD   rD   rE   get_plugin_managerF  s   r   list[str] | os.PathLike[str]c                 C  s   t | tjrt| g} nt | tsd}t|| t| t| |}|j	}z"|r>|D ]}t |t
r8|| q+|| q+|jj|| d}|W S  tyT   |   w )NzG`args` parameter expected to be a list of strings, got: {!r} (type: {}))r   rs   )r   r[   PathLikefspathlist	TypeErrorformatrS   r   r   rP   consider_pluginargregisterr   pytest_cmdline_parseBaseExceptionr   )rs   rw   rt   initial_configr   pluginr~   rD   rD   rE   r   Q  s,   


r   rH   c                 C  s   |   r| jS | S )z<Get the directory of a path - itself if already a directory.)is_fileparent)rG   rD   rD   rE   _get_directoryo  s   r   methodr   	hook_type	opt_namestuple[str, ...]dict[str, bool]c           
      C  s   t r	t| s	J dd t| dg D }g }i }|D ]0}t| |t}|tur5|| d|  d||< q||v rF|| d d||< qd||< q|red|}tjj	j
|| j|d	}	ttt| |	 |S )
Nc                 S  s   h | ]}|j qS rD   name).0mrD   rD   rE   	<setcomp>  s    z)_get_legacy_hook_marks.<locals>.<setcomp>
pytestmark=Tz=TrueF, )rS   fullname	hook_opts)r   inspect	isroutinegetattrAttributeErrorappendjoin_pytest
deprecatedHOOK_LEGACY_MARKINGr   r<   r0   r   r   )
r   r   r   known_marks	must_warnoptsopt_nameopt_attrr   messagerD   rD   rE   _get_legacy_hook_marksw  s.   



r  c                      s
  e Zd ZdZdZ fddZd[ fddZd\ fddZd]d^ fddZd_ddZd`ddZ	daddZ
dbd)d*Zdcd,d-Zddd0d1Zded2d3Zdfd5d6Zdgd8d9Zdhd<d=Zdid?d@ZdAdBdjdEdFZdkdHdIZdldLdMZdZdNdOZdmdPdQZdndTdUZdodpdXdYZ  ZS )qr   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.
    rK   rL   c                   s   ddl m} ddl m} t d t | _i | _d | _d| _	t
dt| _g | _| tj | |  tjdritj}t|dd	}ztt| |jd
|d}W n	 ty\   Y nw | jj|j |    | | _!d| _"d S )Nr   )DummyRewriteHook)RewriteHookr4   F   PYTEST_DEBUGencodingutf8r   )mode	bufferingr  )#_pytest.assertionr  r  superrO   set_conftest_plugins_dirpath2confmods_confcutdir_noconftestr	   r   skipped_pluginsadd_hookspecsr   hookspecr   r[   r   r   r   r   r   r   dupr   r  rJ   traceroot	setwriterr   enable_tracingrewrite_hook_configured)rN   r  r  errr  	__class__rD   rE   rO     s8   


zPytestPluginManager.__init__r   _PluggyPluginr   rP   HookimplOpts | Nonec                   sb   | dsdS |dkrdS t ||}|dur|S t||}t|s&dS 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   )rN   r   r   r  r   legacyr!  rD   rE   r.    s   



z'PytestPluginManager.parse_hookimpl_optsHookspecOpts | Nonec                   sD   t  ||}|du r t||}|dr t|dd}tt|}|S )r%  Nr&  r   )firstresulthistoric)r  parse_hookspec_optsr   r-  r  r   r   )rN   module_or_classr   r  r   r/  r!  rD   rE   r3    s   


z'PytestPluginManager.parse_hookspec_optsN
str | Nonec              	     sv   |t jjv rttd|dd d S t 	||}|d ur9| j
jjt||| dd t|tjr9| | |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   r   pytest_plugin_registeredcall_historicdictr   types
ModuleTypeconsider_module)rN   r   r   r8  r!  rD   rE   r     s,   

zPytestPluginManager.registerc                 C  s   |  |}|S rM   )
get_plugin)rN   r   r   rD   rD   rE   	getplugin  s   
zPytestPluginManager.getpluginrX   c                 C  s   t | |S )z:Return whether a plugin with the given name is registered.)rX   rE  )rN   r   rD   rD   rE   	hasplugin     zPytestPluginManager.haspluginr~   r   c                 C  s"   | dd | dd d| _dS )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  )rN   r~   rD   rD   rE   pytest_configure  s   
z$PytestPluginManager.pytest_configurers   Sequence[str | pathlib.Path]pyargs
noconftestrootpathrH   
confcutdirpathlib.Path | Noneinvocation_dir
importmodeImportMode | strconsider_namespace_packagesc                C  s   |rt || nd| _|| _|| _d}	|D ]*}
t|
}|d}|dkr*|d| }t || }t|r?| j||||d d}	q|	sM| j||||d dS dS )a`  Load initial conftest files given a preparsed "namespace".

        As conftest files may add their own command line options which have
        arguments ('--my-opt somepath') we might get some false positives.
        All builtin and 3rd party plugins will have been loaded, however, so
        common options will not confuse our logic here.
        NF::rU  T)r(   r  r  _using_pyargsrP   findr-   _try_load_conftest)rN   rs   rM  rN  rO  rP  rR  rS  rU  foundanchorinitial_pathrG   ianchorrD   rD   rE   _set_initial_conftests3  s8   

z*PytestPluginManager._set_initial_conftestsrG   c                 C  s   | j du rdS || j jvS )z:Whether to consider the given path to load conftests from.NT)r  parentsrN   rG   rD   rD   rE   _is_in_confcutdirf  s   

z%PytestPluginManager._is_in_confcutdirr_  str | ImportModec                C  sL   | j ||||d | r"|dD ]}| r!| j ||||d qd S d S )NrX  ztest*)_loadconftestmodulesis_dirglob)rN   r_  rS  rO  rU  xrD   rD   rE   r[  u  s$   z&PytestPluginManager._try_load_conftestc          
      C  s   | j rd S | |}|| jv rd S g }t|g|jR D ]}| |r9|d }| r9| j||||d}	||	 q|| j|< d S )Nzconftest.pyrX  )	r  r   r  reversedra  rc  r   _importconftestr   )
rN   rG   rS  rO  rU  	directoryclistr   conftestpathmodrD   rD   rE   re    s&   



z(PytestPluginManager._loadconftestmodulesSequence[types.ModuleType]c                 C  s   |  |}| j|dS )NrD   )r   r  r   )rN   rG   rk  rD   rD   rE   _getconftestmodules  s   
z'PytestPluginManager._getconftestmodulestuple[types.ModuleType, Any]c              	   C  sF   |  |}t|D ]}z
|t||fW   S  ty   Y q	w t|rM   )rp  ri  r   r   KeyError)rN   r   rG   modulesrn  rD   rD   rE   _rget_with_confmod  s   
z&PytestPluginManager._rget_with_confmodrm  types.ModuleTypec             
   C  sB  t |}| |}|d urttj|S t|}|d u r,ztj|j= W n	 t	y+   Y nw z
t
||||d}W n tyP }	 z|	jd usEJ t||	d|	d }	~	ww | || | j| |j}
|
| jv r| j D ]%\}}|
|jv sw||
kr||v rtd|d| d|j d|| qj| d| | j||d |S )	N)r  r  rU  )rI   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)rP   rE  r   rB  rC  r,   r   rs  stemrr  r*   rJ   __traceback__rF   _check_non_top_pytest_pluginsr  addr   r  itemsra  AssertionError__file__r   r  consider_conftest)rN   rm  rS  rO  rU  conftestpath_plugin_nameexistingpkgpathrn  r^   dirpathrG   modsrD   rD   rE   rj    sT   



z#PytestPluginManager._importconftestrn  c                 C  s@   t |dr| jr| jsd}t||| jdd d S d S d S d S )Nr'  af  Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:
It affects the entire test suite instead of just below the conftest as expected.
  {}
Please move it to a top level conftest file at the rootdir:
  {}
For more information, visit:
  https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-filesF)pytrace)hasattrr  rY  r&   r   r  )rN   rn  rm  rt   rD   rD   rE   ry    s   	z1PytestPluginManager._check_non_top_pytest_pluginsFr   Sequence[str]r   c                C  s   d}t |}||k rU|| }|d7 }t|trO|dkr1z|| }W n
 ty+   Y dS w |d7 }n|dr=|dd }nq| }|rJ|dsJq| | ||k s
dS dS )r%  r   r   z-pNr6   no:)lenr   rP   
IndexErrorr-  stripr   )rN   rs   r   r^  noptpargrD   rD   rE   r     s*   



z%PytestPluginManager.consider_preparseargc                 C  s   | dr:|dd }|tv rtd| d|dkr%| d | d | | | d	s8| d	|  dS dS |}| | | d	sM| d	|  | j|d
d dS )r%  r  r7   Nzplugin z cannot be disabledr   r   pytest_stepwiser&  T)consider_entry_points)r-  essential_pluginsr   set_blockedunblockr   )rN   r  r   rD   rD   rE   r   '  s    






z&PytestPluginManager.consider_pluginargconftestmodulerv  c                 C  s   | j ||d dS )r%  r   N)r   )rN   r  rv  rD   rD   rE   r~  >  s   z%PytestPluginManager.consider_conftestc                 C  s   |  tjd dS )r%  PYTEST_PLUGINSN)_import_plugin_specsr[   r   r   rT   rD   rD   rE   consider_envD     z PytestPluginManager.consider_envc                 C  s   |  t|dg  dS )r%  r'  N)r  r   )rN   rn  rD   rD   rE   rD  H  r  z#PytestPluginManager.consider_moduler   -None | types.ModuleType | str | Sequence[str]c                 C  s    t |}|D ]}| | qd S rM   )_get_plugin_specs_as_listr   )rN   r   rw   import_specrD   rD   rE   r  L  s   z(PytestPluginManager._import_plugin_specsmodnamer  c              
   C  s  t |tsJ d|| |s| |durdS |tv r"d| n|}| j| |r7| jd|d}|r7dS zt| W n; t	y[ } zt	d| d|j
d  |j|d}~w tyx } z| j||jpjd	f W Y d}~dS d}~ww tj| }| || dS )
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   rP   
is_blockedrE  builtin_pluginsr  mark_rewriteload_setuptools_entrypoints
__import__ImportErrorrs   with_tracebackrx  r'   r  r   rt   r   rs  r   )rN   r  r  
importspecloadedr^   rn  rD   rD   rE   r   S  s4   

$
z!PytestPluginManager.import_pluginrK   rL   )r   r#  r   rP   rK   r$  )r   rP   rK   r0  rM   )r   r#  r   r5  rK   r5  r   rP   )r   rP   rK   rX   )r~   r   rK   rL   )rs   rL  rM  rX   rN  rX   rO  rH   rP  rQ  rR  rH   rS  rT  rU  rX   rK   rL   )rG   rH   rK   rX   )
r_  rH   rS  rd  rO  rH   rU  rX   rK   rL   )
rG   rH   rS  rd  rO  rH   rU  rX   rK   rL   )rG   rH   rK   ro  )r   rP   rG   rH   rK   rq  )
rm  rH   rS  rd  rO  rH   rU  rX   rK   ru  )rn  ru  rm  rH   rK   rL   )rs   r  r   rX   rK   rL   )r  rP   rK   rL   )r  ru  rv  rP   rK   rL   )rn  ru  rK   rL   )r   r  rK   rL   )F)r  rP   r  rX   rK   rL   )r:   r;   r<   r=   rO   r.  r3  r   rF  rG  rK  r`  rc  r[  re  rp  rt  rj  ry  r   r   r~  r  rD  r  r   __classcell__rD   rD   r!  rE   r     s2    4




3


 


5




specsr  	list[str]c                 C  s\   | du rg S t | tjrg S t | tr| r| dS g S t | tjjr't| S t	d| )z:Parse a plugins specification into a list of plugin names.N,zWPlugins may be specified as a sequence or a ','-separated string of plugin names. Got: )
r   rB  rC  rP   rZ   collectionsabcr   r   r   )r  rD   rD   rE   r  y  s   
r  c                   @  s   e Zd Zdd ZdS )Notsetc                 C  s   dS )Nz<NOTSET>rD   rT   rD   rD   rE   __repr__  s   zNotset.__repr__N)r:   r;   r<   r  rD   rD   rD   rE   r    r   r  package_filesIterable[str]Iterator[str]c                 c  s    t | } d}| D ]=}d|vo|d}|ddko|d}|r9tj|\}}|dkr8|ds8d}|V  q	|rFtj|}d}|V  q	|spg }| D ]}|d}	d	|	dd	 }
|
rd|
|
 qM|rrt|E d	H  d	S d	S d	S )
aM  Given an iterable of file names in a source distribution, return the "names" that should
    be marked for assertion rewrite.

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

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

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

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

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

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

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

    More information:
        https://github.com/pytest-dev/pytest-mock/issues/167
    F/z.pyr   z__init__.pysetup__editable__TN)r   endswithr   r[   rG   splitextr-  dirnamerZ   r   r   _iter_rewritable_modules)r  	seen_somefnis_simple_module
is_packagemodule_namer6  package_namenew_package_filespartsnew_fnrD   rD   rE   r    s:    

r  c                   @  s^  e Zd ZU dZeejddG dd dZG dd dej	Z
ded	< d
ddddZedddZedddZdddZdddZdd d!Zdd#d$Zdd'd(Z	
ddd-d.Zdd1d2Zedd5d6Zdd9d:Zedd;dd=d>Zdd?d@ZddEdFZddGdHZddIdJZddLdMZ ddTdUZ!eddVddXdYZ"ddZd[Z#dd\d]Z$dd^d_Z%ddadbZ&ddddeZ'dddgdhZ(ddmdnZ)ddqdrZ*ddtduZ+ddydzZ,dd{d|Z-dddZ.dddZ/dddZ0e1dfdddZ2ddddZ3ddddZ4dZ5ded< dZ6ded< dZ7ded< dZ8ded< ddddZ9e:dddZ;e:dddZ<dddZ=dddZ>d
S )r   a  Access to configuration values, pluginmanager and plugin hooks.

    :param PytestPluginManager pluginmanager:
        A pytest PluginManager.

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

        The object attributes are read-only.

        .. versionadded:: 5.1

        .. note::

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

            Plugins accessing ``InvocationParams`` must be aware of that.
        r   rs   rx   rw   rH   r   r  rK   rL   c                C  s2   t | dt| t | d| t | d| d S )Nrs   rw   r   )object__setattr__tuple)rN   rs   rw   r   rD   rD   rE   rO     s   z Config.InvocationParams.__init__N)rs   r  rw   rx   r   rH   rK   rL   )r:   r;   r<   r=   __annotations__rO   rD   rD   rD   rE   r     s   
 r   c                   @  s,   e Zd ZdZe Ze ZeZe Z	dS )zConfig.ArgsSourcezSIndicates the source of the test arguments.

        .. versionadded:: 7.2
        N)
r:   r;   r<   r=   enumautoARGSINVOCATION_DIRINCOVATION_DIR	TESTPATHSrD   rD   rD   rE   
ArgsSource  s    r  r2   cacheNr   r   r   r   InvocationParams | NonerK   rL   c                C  s   |d u r| j dd tj d}t | _	 || _	 tdt	 dt	 d| j
dd| _|| _	 t | _	 | j| _| jjjd| _t| jj| _i | _i | _t | _| j| d	 d
| _| jjjt| j| jdd tj j!| _"g | _#d S )NrD   r   z%(prog)s [options] [z] [z] [...]T)usage
processopt	_ispytestr~   pytestconfigF)parserr   r:  )$r   r   r   r   argparse	Namespaceoptionr   r%   r$   _processopt_parserr   r.   stash_storer  r  r   r   r   	_inicache	_opt2dest
contextlib	ExitStack_cleanup_stackr   r  pytest_addoptionr@  rA  r   r  r  args_sourcers   )rN   r   r   rD   rD   rE   rO     s<   



zConfig.__init__rH   c                 C     | j S )zQThe path to the :ref:`rootdir <rootdir>`.

        .. versionadded:: 6.1
        )	_rootpathrT   rD   rD   rE   rO  O     zConfig.rootpathrQ  c                 C  r  )zXThe path to the :ref:`configfile <configfiles>`.

        .. versionadded:: 6.1
        )_inipathrT   rD   rD   rE   inipathW  r  zConfig.inipathfuncCallable[[], None]c                 C  s   | j | dS )zAdd a function to be called when the config object gets out of
        use (usually coinciding with pytest_unconfigure).
        N)r  callback)rN   r  rD   rD   rE   add_cleanup_  s   zConfig.add_cleanupc                 C  s*   | j rJ d| _ | jjjt| dd d S )NTr}   r:  )r  r   rK  r@  rA  rT   rD   rD   rE   _do_configuree  s   
zConfig._do_configurec                 C  s   z0| j rd| _ z| jj| d W g | jj_ng | jj_w W z| j  W t | _d S t | _w z| j  W t | _w t | _w )NFr}   )	r  r   pytest_unconfigurerK  _call_historyr  closer  r  rT   rD   rD   rE   r   j  s   zConfig._ensure_unconfigurer!   c                 C  s   | j d}|d usJ |jS )Nterminalreporter)r   rE  _tw)rN   r  rD   rD   rE   get_terminal_writerx  s
   zConfig.get_terminal_writerrs   r  c                 C  s   z|  | W | S  tyA   t| jddsd|v r%ddlm} ||   t| jdds4d|v s4d|v r@| jj  t	j
d	  w )
NversionFrz   r   )show_version_verbosehelpz--helpz-hz8
NOTE: displaying only minimal help due to UsageError.

)parser   r   r  _pytest.helpconfigr  r  	optparser
print_helpr   r   r   )rN   r   rs   r  rD   rD   rE   r     s"   	zConfig.pytest_cmdline_parseexcinfoExceptionInfo[BaseException]r  argparse.Namespace | Nonec                 C  s   |rt |ddrd}nd}|jdt |dd|d}| jj||d}t|s>t|d	D ]}tj	d
| d	 tj
  q,d S d S )N	fulltraceFlongnativeT
showlocals)funcargsr  rc   )excreprr  rr   zINTERNALERROR> )r   ri   r   pytest_internalerroranyrP   rZ   r   r   r   r   )rN   r  r  rc   r  resrf   rD   rD   rE   notify_exception  s   zConfig.notify_exceptionnodeidrP   c                 C  sH   | j j| jkr"|d^}}| j| }t| j j|}d|g|}|S )NrV  )r   r   rO  rZ   r)   r   )rN   r
  base_path_partnodeid_partfullpathrelative_pathrD   rD   rE   cwd_relative_nodeid  s   
zConfig.cwd_relative_nodeidoption_dictMapping[str, Any]c                 C  sB   t |}|jj| |j|dd |jjD ]}|j| q|S )z$Constructor usable for subprocesses.F)addopts)r   r  __dict__updater  rw   r   r   )clsr  rs   r~   rh  rD   rD   rE   fromdictargs  s   zConfig.fromdictargsr  r#   c                 C  sT   |j |j D ]}|j| j|< qt|dr&t| j|js(t| j|j|j d S d S d S )Ndefault)_short_opts
_long_optsdestr  r  r  setattrr  )rN   r  r   rD   rD   rE   r    s   
zConfig._processopt)r*  early_configc                 C  sj   |j |jj|jj|d|jj|jdd\}}| jj	||jj|jj
|j|jj|jj|jj|dd d S )N	testpathsFrs   rM  r  rR  rO  r=  rU  )rs   rM  rN  rO  rP  rR  rS  rU  )_decide_argsknown_args_namespacefile_or_dirrM  getinir   r   rO  r   r`  rN  rP  rS  )rN   r  rs   _args_sourcerD   rD   rE   pytest_load_initial_conftests  s(   

z$Config.pytest_load_initial_conftestsc                 C  s~   t | jdd}t | jddpttjd}|dkr8ddl}z|j| }W n t	y1   d}Y nw | 
|| | | dS )	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   r   rX   r[   r   r   r  r   install_importhookSystemError_mark_plugins_for_rewrite_warn_about_missing_assertion)rN   r  disable_autoloadr   r   rD   rD   rE   _consider_importhook  s   zConfig._consider_importhookr   r1   r.  rX   c                 C  s@   || j _|rdS dd tj D }t|D ]}|| qdS )zGiven an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins.Nc                 s  s<    | ]}t d d |jD r|jpg D ]}t|V  qqdS )c                 s  s    | ]}|j d kV  qdS )r  N)group)r   eprD   rD   rE   	<genexpr>  s    z=Config._mark_plugins_for_rewrite.<locals>.<genexpr>.<genexpr>N)r  entry_pointsfilesrP   )r   distr_   rD   rD   rE   r2    s    z3Config._mark_plugins_for_rewrite.<locals>.<genexpr>)r   r  rY   metadatadistributionsr  r  )rN   r   r.  r  r   rD   rD   rE   r,    s   z Config._mark_plugins_for_rewritec                 C  s6   t | dD ]}tjdt| q| | j d S )N
pythonpathr   )ri  r"  r   rG   insertrP   r  _unconfigure_python_pathrb  rD   rD   rE   _configure_python_path  s   zConfig._configure_python_pathc                 C  s2   |  dD ]}t|}|tjv rtj| qd S )Nr8  )r"  rP   r   rG   remove)rN   rG   path_strrD   rD   rE   r:    s   
zConfig._unconfigure_python_pathviac              
   C  sN   || j jd< z| j j|t| jd W | j jdd |S | j jdd w )zValidate known args.zconfig source	namespaceN)r  
extra_infoparse_known_and_unknown_argscopyr  r   )rN   rs   r>  rD   rD   rE   _validate_args  s   zConfig._validate_argsrM  r  rR  rO  r=  tuple[list[str], ArgsSource]c                C  s   |rt jj}|}||fS ||kr>t jj}|r|}n'g }|D ]}	|ttj|	dd q|r=|s=|r=d}
| jt	|
dd ng }|sKt 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sortedrg  iglobissue_config_time_warningr/   r  rP   )rN   rs   rM  r  rR  rO  r=  sourceresultrG   warning_textrD   rD   rE   r  *  s0   
zConfig._decide_args)wrapperGenerator[None, object, object]c                 c  s    zd V W |    S |    w rM   )_validate_config_optionsrT   rD   rD   rE   pytest_collectionW  s   zConfig.pytest_collectionc                 C  s   dd l }| jdd }|d ur|jnd }|rCddlm} t|ts*|| j	 d||||j
krE|| j	 d| d|j
 dd S d S )Nr   
minversionVersionz%: 'minversion' must be a single valuez: 'minversion' requires pytest-z, actual pytest-')r4   inicfgr   valuepackaging.versionrV  r   rP   r   r  r   )rN   r4   minver_ini_valueminverrV  rD   rD   rE   _checkversion`  s   

	zConfig._checkversionc                 C  s(   t |  D ]}| d| d qd S )NzUnknown config option: rr   )rJ  _get_unknown_ini_keys_warn_or_fail_if_strict)rN   keyrD   rD   rE   rR  s  s   zConfig._validate_config_optionsc           
   	   C  s   t | d}|sd S ddlm} ddlm} ddlm} | j }dd |D }g }|D ]4}z||}	W n |yC   |	| Y q-w |	j
|vrO|	| q-|	jj|||	j
 dd	sa|	| q-|rntd
d|d S )Nrequired_pluginsr   )InvalidRequirement)RequirementrU  c                 S  s   i | ]	\}}|j |jqS rD   )project_namer  )r   r6  r5  rD   rD   rE   
<dictcomp>  s    z,Config._validate_plugins.<locals>.<dictcomp>T)prereleaseszMissing required plugins: {}r   )rJ  r"  packaging.requirementsrb  rc  rZ  rV  r   list_plugin_distinfor   r   	specifiercontainsr   r   r   )
rN   ra  rb  rc  rV  plugin_infoplugin_dist_infomissing_pluginsrequired_pluginreqrD   rD   rE   _validate_pluginsw  s8   



zConfig._validate_pluginsr  c                 C  s>   |  d}|d u r|  d}|rt|| jt|dd d S )Nstrict_configstrictr7   rG  )r"  r   rL  r/   )rN   r  rq  rD   rD   rE   r_    s   

zConfig._warn_or_fail_if_strictset[str]c                 C  s&   | j j | j j B }| j | S rM   )r  _inidictkeys_ini_aliasesrX  )rN   
known_keysrD   rD   rE   r^    s   zConfig._get_unknown_ini_keysr  c              
   C  s  | j g ks	J d| jjjt| jdd |r1tjdd}t	|r1| 
t|d| |d d < | jj|t| jd}t|j|j|j|jpHd | jjd\}}}}|| _|| _|| _|| _t| j| jjd	< t| j| jjd
< | j ddd | j dd | jj dddg d | jj dddg d |r| 
| !dd| |d d < | jj|t| jd| _"| #  | $  | %  | jj&|dd tjds| j"j's| j(d | j)  | jj|| j"d | *  | +  | j"j,d u r| jd urt| jj-}	nt| j}	|	| j"_,z| jj.| || jd W n, t/y? }
 z| j"j0s&| j"j1r4| j2t3d|
j4 dd n W Y d }
~
nd }
~
ww z| jj5|| jd W n t6yV   Y d S w | j7t8| jt9| jj:| !d | jj| jd!d"\| _ | _;d S )#Nz:can only parse cmdline args at most once per Config object)r   r:  PYTEST_ADDOPTSr  zvia PYTEST_ADDOPTSr?  )inifileoverride_inirs   rootdir_cmd_argrR  rootdirry  r  zExtra command line optionsrs   rT  z!Minimally required pytest versionr8  pathszAdd paths to sys.path)rS   r  r  ra  z.Plugins that must be present for pytest to run)rS   r  zvia addopts configFr   r(  r  )r  rs   r  z"could not load initial conftests: r6   rG  r  Tr  )<rs   r   pytest_addhooksr@  rA  r   r[   r   r   r  rD  shlexrZ   r  parse_known_argsrC  r  r   inifilenamerz  r!  r|  r   r   r  r  _ignored_config_filesrX  rP   rO  rA  r  addinir"  r   r]  r/  r;  r   r'  r  r  rp  _warn_about_skipped_pluginsrP  r   r$  rF   r  r  rL  r/   rG   r  r   r  r   r$   rM  r  )rN   rs   r  env_addoptsnsrO  r  rX  ignored_config_filesrP  r^   rD   rD   rE   r    s   








zConfig.parsewarningWarningrH  r   c                 C  s   | j drdS | jjpg }| d}tjdd}tdt| t	|| tj
||d W d   n1 s8w   Y  |rbt|d }|jj|j|jjf}| jjjt|d	 d
d|dd dS dS )a  Issue and handle a warning during the "configure" stage.

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

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

        :param warning: The warning instance.
        :param stacklevel: stacklevel forwarded to warnings.warn.
        r   NfilterwarningsT)recordalwaysrG  r   r   r~   r  )warning_messagewhenr
  locationr:  )r   r  r   pythonwarningsr"  r   catch_warningssimplefilterrS   apply_warning_filtersr=  r   	_getframef_codeco_filenamef_linenoco_namer   pytest_warning_recordedr@  rA  )rN   r  rH  cmdline_filtersconfig_filtersrecordsframer  rD   rD   rE   rL    s*   


z Config.issue_config_time_warningr   rf   c                 C  s&   |  |}t|tsJ || dS )zAdd a line to a configuration 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   )rN   r   rf   rh  rD   rD   rE   rJ  4  s   
zConfig.addinivalue_liner   c                 C  sH   | j j||}z| j| W S  ty   Y nw | | | j|< }|S )a~  Return configuration value the an :ref:`configuration file <configfiles>`.

        If a configuration value is not defined in a
        :ref:`configuration 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  rv  r   r  rr  _getini)rN   r   canonical_namevalrD   rD   rE   r"  <  s   zConfig.getinirS   rY  r  c                 C  s   d| d| d|}t |)NzOption z  has unknown configuration type z with value )r   )rN   r   rS   rY  rt   rD   rD   rE   _getini_unknown_typed  s   zConfig._getini_unknown_typec              
   C  s(  | j j||}z| j j| \}}}W n ty' } ztd||d }~ww g }|| jv r9|| j| df | j j D ]\}}	|	|krV|| jv rV|| j| df q?|s[|S t	|dd dd }
|
j
}|
j}|dkrt|ttfsxJ | |||||S |d	kr| |||||S t| d S )
Nzunknown configuration value: TFc                 S  s   | d j dk| d fS )Nr   overrider   )originrh  rD   rD   rE   <lambda>  s    z Config._getini.<locals>.<lambda>)r`  r   initoml)r  rv  r   rt  rr  r   rX  r   r{  maxrY  r  r   rP   r   _getini_ini_getini_tomlr"   )rN   r   r  _descriptionrS   r  r^   
candidatesaliastargetselectedrY  r  rD   rD   rE   r  j  s2   
zConfig._getinir  str | list[str]r  c                   s2  |dkr&| j dur| j jn| jj t|trt|n|} fdd|D S |dkr6t|tr4t|S |S |dkrPt|trNdd tdd	 |d
D S |S |dkr\t	t|
 S |dkrb|S |dkrzt|tsvtd| d|dt|S |dkrt|tstd| d|dt|S | |||S )zHandle config values read in INI mode.

        In INI mode, values are stored as str or list[str] only, and coerced
        from string based on the registered type.
        r}  Nc                      g | ]} | qS rD   rD   r   rh  dprD   rE   
<listcomp>      z&Config._getini_ini.<locals>.<listcomp>rs   linelistc                 S  s   g | ]}|r|qS rD   rD   )r   trD   rD   rE   r    r  c                 S  s   |   S rM   r  r  rD   rD   rE   r    s    z$Config._getini_ini.<locals>.<lambda>rr   rX   stringr   z"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   r   r   r   rP   r  rZ   map
_strtoboolr  r   r   r  r  )rN   r   r  rS   rY  r  input_valuesrD   r  rE   r    sD   



zConfig._getini_inic           
        sJ  t |j}|dkr\t|tst| j d| d| d|t|D ]"\}}t|tsEt |j}	t| j d| d| d|	 d|	q#| jdurO| jj	n| j
j  fdd	|D S |d
v rt|tsxt| j d| d| d| d|	t|D ]"\}}t|tst |j}	t| j d| d| d|	 d|	q|t|S |dkrt|tst| j d| d| d||S |dkrt|trt|trt| j d| d| d||S |dkrt|ttfrt|trt| j d| d| d||S |dkrt|tst| j d| d| d||S | |||S )zHandle TOML config values with strict type validation and no coercion.

        In TOML mode, values already have native types from TOML parsing.
        We validate types match expectations exactly, including list items.
        r}  z: config option 'z'' expects a list for type 'paths', got rQ   z/' expects a list of strings, but item at index z is Nc                   r  rD   rD   r  r  rD   rE   r    r  z'Config._getini_toml.<locals>.<listcomp>>   rs   r  z' expects a list for type 'z', got rX   z' expects a bool, got r   z' expects an int, got r  z' expects a float, got r  z' expects a string, got )builtinsrS   r:   r   r   r   r  	enumeraterP   r   r   r   rX   r   r  r  )
rN   r   r  rS   rY  r  
value_typer^  item	item_typerD   r  rE   r    s   







zConfig._getini_tomlrG   list[pathlib.Path] | Nonec                 C  s   z| j ||\}}W n
 ty   Y d S w |jd usJ t|jj}g }|D ] }t|tj	r6t|}n|
dtj}t|| }|| q(|S )Nr  )r   rt  rr  r}  r   r   r   r   r[   r   r>  r\   r(   r   )rN   r   rG   rn  relrootsmodpathvaluesrelrootrD   rD   rE   _getconftest_pathlist   s   zConfig._getconftest_pathlistFskipc              
   C  s   | j ||}zt| j|}|du r|rt||W S  tyI } z#|tur.|W  Y d}~S |r=ddl}|d|d td||d}~w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  r   r   r  r   notsetr4   r  r   )rN   r   r  r  r  r^   r4   rD   rD   rE   	getoption3  s   
zConfig.getoptionc                 C  s
   |  |S )z$Deprecated, use getoption() instead.r  rN   r   rG   rD   rD   rE   getvalueL     
zConfig.getvaluec                 C  s   | j |ddS )z-Deprecated, use getoption(skip=True) instead.T)r  r  r  rD   rD   rE   getvalueorskipP  rH  zConfig.getvalueorskip
assertionsr   VERBOSITY_ASSERTIONS
test_casesVERBOSITY_TEST_CASESr   VERBOSITY_SUBTESTSr  _VERBOSITY_INI_DEFAULTverbosity_typer5  c                 C  sb   | j ddd}t|tsJ |du r|S t|}|| jjvr!|S | |}|tjkr-|S t|S )a  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:

        .. tab:: toml

            .. code-block:: toml

                [tool.pytest]
                verbosity_assertions = 2

        .. tab:: ini

            .. code-block:: ini

                [pytest]
                verbosity_assertions = 2

        .. code-block:: console

            pytest -v

        .. code-block:: python

            print(config.get_verbosity())  # 1
            print(config.get_verbosity(Config.VERBOSITY_ASSERTIONS))  # 2
        verboser   )r  N)	r  r   r   r   _verbosity_ini_namer  rt  r"  r  )rN   r  global_levelini_namelevelrD   rD   rE   get_verbosity]  s   '


zConfig.get_verbosityc                 C  s
   d|  S )N
verbosity_rD   )r  rD   rD   rE   r    r  zConfig._verbosity_ini_namer  r%   r  c                 C  s   | j t||dtjd dS )a  Add a output verbosity configuration option for the given output type.

        :param parser: Parser for command line arguments and config-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  rS   r  N)r  r   r  r  )r  r  r  rD   rD   rE   _add_verbosity_ini  s   
zConfig._add_verbosity_inir  c                 C  s2   t  s|dkr
d}nd}| jt|dd d S d S )Nr&  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   rG  )_assertion_supportedrL  r/   )rN   r  rO  rD   rD   rE   r-    s   
z$Config._warn_about_missing_assertionc                 C  s4   | j jD ]\}}| jtd|d| dd qd S )Nzskipped plugin rQ   r6   rG  )r   r  rL  r/   )rN   r  rt   rD   rD   rE   r    s   z"Config._warn_about_skipped_plugins)r   r   r   r  rK   rL   )rK   rH   )rK   rQ  )r  r  rK   rL   r  )rK   r!   )r   r   rs   r  rK   r   rM   )r  r  r  r  rK   rL   )r
  rP   rK   rP   )r  r  rs   r  rK   r   )r  r#   rK   rL   )r  r   rK   rL   )r   r1   r.  rX   rK   rL   )rs   r  r>  rP   rK   r  )rs   r  rM  rX   r  r  rR  rH   rO  rH   r=  rX   rK   rE  )rK   rQ  )r  rP   rK   rL   )rK   rs  )T)rs   r  r  rX   rK   rL   )r  r  rH  r   rK   rL   )r   rP   rf   rP   rK   rL   )r   rP   rK   r   )r   rP   rS   rP   rY  r  r  )
r   rP   r  rP   rS   rP   rY  r  r  r   )
r   rP   r  rP   rS   rP   rY  r  r  r   )r   rP   rG   rH   rK   r  )r   rP   r  r   r  rX   )r  r5  rK   r   )r  rP   rK   rP   )r  r%   r  rP   r  rP   rK   rL   )r  rP   rK   rL   )?r:   r;   r<   r=   r   dataclasses	dataclassr   r  Enumr  r  rO   propertyrO  r  r  r  r   r  r   r	  r  classmethodr  r  hookimplr$  r/  r,  r;  r:  rD  r  rS  r]  rR  rp  r_  r^  r  rL  rJ  r"  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r-  r  rD   rD   rD   rE   r     s|   
 

!8






	





-



!
	
l
#

(

%
=
T6
c                   C  s   zJ  t y   Y dS w )NFT)r|  rD   rD   rD   rE   r    s
   r  r~   TextIO | Noner!   c                 C  s\   t |d}| 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.
    r|   yesTnoF)r!   r  color	hasmarkupcode_highlight)r~   r_   rn   rD   rD   rE   create_terminal_writer  s   
	r  r  c                 C  s.   |   } | dv r
dS | dv rdS 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 )lowerr   )r  rD   rD   rE   r    s   	r  2   )maxsizer  escape9tuple[warnings._ActionKind, str, type[Warning], str, int]c             
   C  s  d}t d|  d}| d}t|dkr,d}t dt| d| d	}t|j|d
t|dk r=|d t|dk s2dd |D \}}}	}
}zt|}W n tjyh } zt|jt	|d
dd}~ww zt
|	}W n! tyw     ty   t }|jdd}t|j|d
dw |r|rt|}|
r|rt|
d }
|rzt|}|dk rtdW n ty } zt|jd|d| d
dd}~ww d}zt| t|
 W n tjy } zt|jd|jd| d
dd}~ww ||||
|fS )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                 s  s    | ]}|  V  qd S rM   r  )r   srD   rD   rE   r2  $  s    z'parse_warning_filter.<locals>.<genexpr>Nr  )rc   z\Zr   znumber is negativezinvalid lineno rQ   zInvalid regex )r
   rZ   r  r   r   r   r   
_getaction_OptionErrorrP   _resolve_warning_categoryr  rJ   r   from_currentri   rer  r   r   compiler  pattern)r  r  __tracebackhide__error_templater  doc_urlr  action_r  	category_modulelineno_actionr^   categoryrm   exception_textlinenorD   rD   rE   parse_warning_filter  s   
	


r  r  type[Warning]c                 C  sr   d}| st S d| vrddl}| }n| d\}}}t|dd|g}t||}t|t s2t| 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  r  
rpartitionr  r   
issubclassr   r   rS   )r  r  r   klassr  r6  catrD   rD   rE   r  J  s   

r  r  r  c                 C  s   | D ],}zt jt|dd  W q ty. } zt d|j d| t W Y d}~qd}~ww |D ],}zt jt|dd  W q1 ty] } zt d|j d| t W Y d}~q1d}~ww dS )z8Applies pytest-configured filters to the warnings moduleF)r  z Failed to import filter module 'z': NT)r   r  r  r  r=  r   r/   )r  r  r  r^   rD   rD   rE   r  `  s*   r  )rV   rW   rK   rX   )r^   rF   r_   r   rK   rL   )r^   r   r_   r   rK   rL   )NN)rs   rv   rw   rx   rK   ry   )rK   r   )rG   rP   r   rP   rK   rP   )rs   r   rw   rx   rK   r   )rK   r   rM   )rs   r   rw   rx   rK   r   )rG   rH   rK   rH   )r   r   r   rP   r   r   rK   r   )r  r  rK   r  )r  r  rK   r  )rK   rX   )r~   r   r_   r  rK   r!   )r  rP   rK   rX   )r  rP   r  rX   rK   r  )r  rP   rK   r  )r  r  r  r  rK   rL   )r=   
__future__r   r  r  collections.abcr  r   r   r   r   r   r   r  rC  r  r  	functoolsr	   rg  importlib.metadatarY   r   r[   r   r  r  r   textwrapr
   rB  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.compatr"   _pytest.config.argparsingr#   r$   r%   _pytest.deprecated_pytest.hookspec_pytest.outcomesr&   r'   _pytest.pathlibr(   r)   r*   r+   r,   r-   _pytest.stashr.   _pytest.warning_typesr/   r0   _pytest.assertion.rewriter1   _pytest.cacheproviderr2   _pytest.terminalr3   r  r#  r  r  IntEnumr5   rJ   rF   r]   rq   ru   r   r   r   r   r   r  r   r  r   r   r   r   r  r   r  r  r  r  r   r  r  r  r  r  r  rD   rD   rD   rE   <module>   sp  	



.

	



    
d
A       
u


P