a
    *ñ»j9“  ã                   @  sh  d 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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ZddlZddlmZ ddlZddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl+m-Z- ddl+m.Z. ddl+m/Z/ ddl+m0Z0 ddl1m2Z2 ddl1m3Z3 ddl4m5Z5 dd l4m6Z6 dd!l7m8Z8 e�rîdd"l9m:Z: dd#l;m<Z< d$d%d&œd'd(„Z=d)d)d*œd+d,„Z>d-d.d/d0œd1d2„Z?d-d/d3œd4d5„Z@d-d6d7d8œd9d:„ZAd6d%d;œd<d=„ZBd6d>d;œd?d@„ZCdAd>d*œdBdC„ZDdAd-dDdEœdFdG„ZEdAdHdIdJœdKdL„ZFdMd-d%dNœdOdP„ZGG dQdR„ dRƒZHG dSdT„ dTeIƒZJG dUdV„ dVeKƒZLejMG dWdX„ dXeNeeOf ƒƒZPeG dYdZ„ dZejQƒƒZReG d[d6„ d6ejSƒƒZTd)d\d]œd^d_„ZUejMd`da�G dbdc„ dcƒƒZVdddeœdAd)d>dcdfœdgdh„ZWdS )izHCore implementation of the testing process: init, session, runtest loop.é    )ÚannotationsN)ÚCallable)ÚIterable)ÚIterator)ÚSequence)ÚSet)ÚPath)Úfinal)ÚLiteral)Úoverload)ÚTYPE_CHECKING)Únodes)ÚConfig)Údirectory_arg)ÚExitCode)Úhookimpl)ÚPytestPluginManager)Ú
UsageError)ÚParser)ÚPathAwareHookProxy)Úexit©Úabsolutepath)Úbestrelpath©Ú
fnmatch_ex)Úsafe_exists)Úscandir)ÚCollectReport)Ú
TestReport)Úcollect_one_node)Ú
SetupState)ÚPytestWarning)ÚSelf)ÚFixtureManagerr   ÚNone)ÚparserÚreturnc              	   C  s   |   dd¡}|jddddddd	� |jd
ddtdddd� |jdddd� |jdddd� |jdddd� |   d¡}|jddddd� | jdddd � |   d!d"¡}|jd#d$d%dd&d� |jd'dd(d� |jd)dd*d+d,� |jd-dd*d.d,� |jd/dd0d1d,� |jd2d3d d4tjtd2d5�d6d7� |jd8dd9d:d;d<� |jd=d>dd?d:d@d<� |jdAddBd:dCd<� |jdDdd:dEdFdG� |jdHdIg dJ¢dKdLdM� | jdNdOdPg dQ¢dR� | jdSdTdPg dR� | jdUdVdWdXdR� | jdYdWd:dZd[� |   d\d]¡}|jd^d_d`tdadbdc� |jddddedfdg� |jdhdid t	d4djdk� d S )lNZgeneralzRunning and selection optionsz-xz--exitfirstÚstore_constÚmaxfailé   z,Exit instantly on first error or failed test)ÚactionÚdestÚconstÚhelpz	--maxfailÚnumÚstorer   z'Exit after first num failures or errors)Úmetavarr+   Útyper,   Údefaultr.   z--strict-configÚ
store_truezbAny warnings encountered while parsing the `pytest` section of the configuration file raise errors)r+   r.   z--strict-markerszVMarkers not registered in the `markers` section of the configuration file raise errorsz--strictz&(Deprecated) alias to --strict-markerszpytest-warningsz-Wz--pythonwarningsÚappendz<Set which warnings to report, see -W option of Python itselfÚfilterwarningsZlinelistz_Each line specifies a pattern for warnings.filterwarnings. Processed after -W/--pythonwarnings.)r2   r.   ÚcollectÚ
collectionz--collectonlyz--collect-onlyz--coz&Only collect tests, don't execute themz--pyargsz1Try to interpret all arguments as Python packagesz--ignoreÚpathz-Ignore path during collection (multi-allowed))r+   r1   r.   z--ignore-globz5Ignore path pattern during collection (multi-allowed)z
--deselectZnodeid_prefixzDDeselect item (via node id prefix) during collection (multi-allowed)z--confcutdirZ
confcutdirÚdir)Úoptnamez1Only load conftest.py's relative to specified dir)r,   r3   r1   r2   r.   z--noconftestZ
noconftestFz Don't load any conftest.py files)r+   r,   r3   r.   z--keepduplicatesz--keep-duplicatesÚkeepduplicateszKeep duplicate testsz--collect-in-virtualenvÚcollect_in_virtualenvz2Don't ignore tests in a local virtualenv directoryz--continue-on-collection-errorsÚcontinue_on_collection_errorsz4Force test execution even if collection errors occur)r+   r3   r,   r.   z--import-modeÚprepend)r?   r5   Ú	importlibZ
importmodez\Prepend/append to sys.path when importing test modules and conftest files. Default: prepend.)r3   Úchoicesr,   r.   Únorecursedirsz)Directory patterns to avoid for recursionÚargs)	z*.eggz.*Ú_darcsÚbuildÚCVSÚdistZnode_modulesÚvenvz{arch})r2   r3   Z	testpathszZDirectories to search for tests when no files or directories are given on the command lineZcollect_imported_testsz@Whether to collect tests in imported modules outside `testpaths`ÚboolTZconsider_namespace_packageszEConsider namespace packages when resolving module names during import)r2   r3   r.   Zdebugconfigz(test session debugging and configurationz-cz--config-fileÚFILEZinifilenamezcLoad configuration from `FILE` instead of trying to locate one of the implicit configuration files.)r1   r2   r,   r.   z	--rootdirÚrootdirz¶Define root directory for tests. Can be relative path: 'root_dir', './root_dir', 'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: '$HOME/root_dir'.)r+   r,   r.   z
--basetempZbasetempz^Base temporary directory for this test run. (Warning: this directory is removed if it exists.))r,   r3   r2   r1   r.   )
ZgetgroupZ
_addoptionZ	addoptionÚintZaddiniÚ	functoolsÚpartialr   ÚstrÚvalidate_basetemp)r&   Úgroup© rR   ú2E:\soccer\ml_env\Lib\site-packages\_pytest/main.pyÚpytest_addoption8   sN   úù	ýýý
üýûýüüüúûúûûûüûüüú	üùrT   rO   ©r9   r'   c                 C  sl   d}| st  |¡‚ddddœdd„}|t ¡ t| ƒ ¡ ƒrDt  |¡‚|t ¡  ¡ t| ƒ ¡ ƒrht  |¡‚| S )NzWbasetemp must not be empty, the current working directory or any parent directory of itr   rI   )ÚbaseÚqueryr'   c                 S  s   | |krdS || j v S )z,Return whether query is an ancestor of base.T)Úparents)rV   rW   rR   rR   rS   Úis_ancestor  s    z&validate_basetemp.<locals>.is_ancestor)ÚargparseZArgumentTypeErrorr   ÚcwdÚabsoluteÚresolve)r9   ÚmsgrY   rR   rR   rS   rP   û   s    


rP   r   z2Callable[[Config, Session], int | ExitCode | None]úint | ExitCode)ÚconfigÚdoitr'   c                 C  sð  t  | ¡}tj|_d}�z:z4|  ¡  d}| jj|d� d}|| |ƒpFd|_W �nl tyl   tj	|_‚ Y �nP t
y†   tj|_Y �n6 ttjf�y   tjj ¡ }tj}t|jtjƒrô|jjdurÎ|jj}|dk rôtj |j› d|jj› d�¡ | jj|d� ||_Y n° t�yº   tj|_tjj ¡ }z|  || j ¡ W nZ tj�yš } z>|jdu�rh|j|_tj t!|ƒj"› d|› d�¡ W Y d}~n$d}~0 0 t|jt#ƒ�r¶tj d	¡ Y n0 W d}t$ %|j&¡ |dk�rJz| jj'||jd
� W nZ tj�yH } z>|jdu�r|j|_tj t!|ƒj"› d|› d�¡ W Y d}~n
d}~0 0 |  (¡  n–d}t$ %|j&¡ |dk�ràz| jj'||jd
� W nZ tj�yÞ } z>|jdu�r¬|j|_tj t!|ƒj"› d|› d�¡ W Y d}~n
d}~0 0 |  (¡  0 |jS )zSkeleton command line program.r   r*   ©Úsessioné   Nz: Ú
)Úexcinfoz(mainloop: caught unexpected SystemExit!
)rc   Ú
exitstatus))ÚSessionÚfrom_configr   ÚOKrg   Z_do_configureÚhookZpytest_sessionstartr   ZUSAGE_ERRORÚFailedÚTESTS_FAILEDÚKeyboardInterruptr   Ú	ExceptionÚ_pytestÚ_codeZExceptionInfoZfrom_currentZINTERRUPTEDÚ
isinstanceÚvalueÚ
returncodeÚsysÚstderrÚwriteÚtypenamer^   Zpytest_keyboard_interruptÚBaseExceptionÚINTERNAL_ERRORZnotify_exceptionÚoptionr2   Ú__name__Ú
SystemExitÚosÚchdirÚ	startpathZpytest_sessionfinishZ_ensure_unconfigure)r`   ra   rc   Z	initstaterf   rg   ÚexcrR   rR   rS   Úwrap_session  sz    

4
ÿ
4
õ
ÿ
4
r‚   ©r`   r'   c                 C  s
   t | tƒS ©N)r‚   Ú_main©r`   rR   rR   rS   Úpytest_cmdline_mainO  s    r‡   rh   zint | ExitCode | None)r`   rc   r'   c                 C  s<   | j j|d� | j j|d� |jr(tjS |jdkr8tjS dS )z[Default command line protocol for initialization, session,
    running tests and reporting.rb   r   N)rk   Úpytest_collectionÚpytest_runtestloopÚtestsfailedr   rm   ÚtestscollectedZNO_TESTS_COLLECTED)r`   rc   rR   rR   rS   r…   S  s    
r…   )rc   r'   c                 C  s   |   ¡  d S r„   )Úperform_collectrb   rR   rR   rS   rˆ   `  s    rˆ   rI   c                 C  s¶   | j r6| jjjs6|  | j › d| j dkr*dnd› d�¡‚| jjjrDdS t| jƒD ]b\}}|d t| jƒk rv| j|d  nd }|jj	j
||d� | jrž|  | j¡‚| jrN|  | j¡‚qNdS )Nz errorr*   ÚsÚ z during collectionT)ÚitemÚnextitem)rŠ   r`   r{   r>   ÚInterruptedZcollectonlyÚ	enumerateÚitemsÚlenrk   Zpytest_runtest_protocolÚ
shouldfailrl   Ú
shouldstop)rc   Úir�   r�   rR   rR   rS   r‰   d  s    ÿ
$r‰   r   c                 C  s:   z |   d¡ ¡ p|   dd¡ ¡ W S  ty4   Y dS 0 dS )añ  Attempt to detect if ``path`` is the root of a Virtual Environment by
    checking for the existence of the pyvenv.cfg file.

    [https://peps.python.org/pep-0405/]

    For regression protection we also check for conda environments that do not include pyenv.cfg yet --
    https://github.com/conda/conda/issues/13337 is the conda issue tracking adding pyenv.cfg.

    Checking for the `conda-meta/history` file per https://github.com/pytest-dev/pytest/issues/12652#issuecomment-2246336902.

    z
pyvenv.cfgz
conda-metaÚhistoryFN)ÚjoinpathÚis_fileÚOSError©r9   rR   rR   rS   Ú_in_venvw  s    þr�   zbool | None)Úcollection_pathr`   r'   c                   sò   ˆ j dkrdS |jdˆ jd�}|p$g }| d¡}|rH| dd„ |D ƒ¡ ˆ |v rTdS |jdˆ jd�}|pjg }| d	¡}|rŽ| d
d„ |D ƒ¡ t‡ fdd„|D ƒƒr¨dS | d¡}|sÂtˆ ƒrÂdS ˆ  ¡ rî| d¡}t‡ fdd„|D ƒƒrîdS d S )NÚ__pycache__TZcollect_ignorerœ   Úignorec                 s  s   | ]}t |ƒV  qd S r„   r   ©Ú.0ÚxrR   rR   rS   Ú	<genexpr>–  ó    z(pytest_ignore_collect.<locals>.<genexpr>Zcollect_ignore_globZignore_globc                 s  s   | ]}t |ƒV  qd S r„   r   r¡   rR   rR   rS   r¤   ¡  r¥   c                 3  s"   | ]}t   tˆ ƒt|ƒ¡V  qd S r„   )ÚfnmatchrO   )r¢   Úglob©rž   rR   rS   r¤   £  r¥   r=   rB   c                 3  s   | ]}t |ˆ ƒV  qd S r„   r   )r¢   Úpatr¨   rR   rS   r¤   ¬  r¥   )	ÚnameZ_getconftest_pathlistÚparentÚ	getoptionÚextendÚanyr�   Úis_dirZgetini)rž   r`   Zignore_pathsZ
excludeoptZignore_globsZexcludegloboptZallow_in_venvZnorecursepatternsrR   r¨   rS   Úpytest_ignore_collectŒ  s8    
ÿ
ÿ


r°   únodes.Collectorznodes.Collector | None)r9   r«   r'   c                 C  s   t j|| d�S )Nrœ   )ÚDirÚfrom_parent©r9   r«   rR   rR   rS   Úpytest_collect_directory²  s    rµ   zlist[nodes.Item])r“   r`   r'   c                 C  sp   t | d¡pg ƒ}|sd S g }g }| D ]&}|j |¡rB| |¡ q&| |¡ q&|rl|jj|d� || d d …< d S )NZdeselect)r“   )Útupler¬   ÚnodeidÚ
startswithr5   rk   Zpytest_deselected)r“   r`   Zdeselect_prefixesÚ	remainingZ
deselectedZcolitemrR   rR   rS   Úpytest_collection_modifyitems¸  s    rº   c                   @  s.   e Zd Zddddœdd„Zddd	œd
d„ZdS )ÚFSHookProxyr   zAbstractSet[object]r%   )ÚpmÚremove_modsr'   c                 C  s   || _ || _d S r„   )r¼   r½   )Úselfr¼   r½   rR   rR   rS   Ú__init__Ë  s    zFSHookProxy.__init__rO   zpluggy.HookCaller)rª   r'   c                 C  s    | j j|| jd�}|| j|< |S )N)Zremove_plugins)r¼   Zsubset_hook_callerr½   Ú__dict__)r¾   rª   r£   rR   rR   rS   Ú__getattr__Ó  s    
zFSHookProxy.__getattr__N)r|   Ú
__module__Ú__qualname__r¿   rÁ   rR   rR   rR   rS   r»   Ê  s   r»   c                   @  s   e Zd ZdZdZdS )r‘   z*Signals that the test run was interrupted.ÚbuiltinsN©r|   rÂ   rÃ   Ú__doc__rR   rR   rR   rS   r‘   Ù  s   r‘   c                   @  s   e Zd ZdZdS )rl   z"Signals a stop as failed test run.NrÅ   rR   rR   rR   rS   rl   ß  s   rl   c                   @  s*   e Zd ZU dZded< dddœdd„ZdS )	Ú_bestrelpath_cacherœ   r   r9   rO   rU   c                 C  s   t | j|ƒ}|| |< |S r„   )r   r9   )r¾   r9   ÚrrR   rR   rS   Ú__missing__é  s    z_bestrelpath_cache.__missing__N)r|   rÂ   rÃ   Ú	__slots__Ú__annotations__rÉ   rR   rR   rR   rS   rÇ   ã  s   
rÇ   c                      s<   e Zd ZdZeddddœ‡ fdd„ƒZdd	œd
d„Z‡  ZS )r²   a  Collector of files in a file system directory.

    .. versionadded:: 8.0

    .. note::

        Python directories with an `__init__.py` file are instead collected by
        :class:`~pytest.Package` by default. Both are :class:`~pytest.Directory`
        collectors.
    r±   r   r#   )r«   r9   r'   c                  s   t ƒ j||d�S )z¦The public constructor.

        :param parent: The parent collector of this Dir.
        :param path: The directory's path.
        :type path: pathlib.Path
        )r«   r9   )Úsuperr³   )Úclsr«   r9   ©Ú	__class__rR   rS   r³   ü  s    zDir.from_parentz&Iterable[nodes.Item | nodes.Collector]©r'   c                 c  s¶   | j }| j}t| jƒD ]š}| ¡ rjt|jƒ}| jj|dd�sL|j||d�rLq|j	|| d�}|d ur°|V  q| 
¡ rt|jƒ}| j |¡s˜|j||d�r˜q|j|| d�}|E d H  qd S )NT©Úwith_parents)rž   r`   r´   ©Ú	file_pathr«   )r`   Úihookr   r9   r¯   r   rc   Ú
isinitpathr°   rµ   rš   Úpytest_collect_file)r¾   r`   rÕ   Zdirentryr9   ÚcolÚcolsrR   rR   rS   r7     s$    

zDir.collect)r|   rÂ   rÃ   rÆ   Úclassmethodr³   r7   Ú__classcell__rR   rR   rÎ   rS   r²   ï  s   r²   c                      sÄ  e Zd ZU dZeZeZded< ded< ded< dd	d
œ‡ fdd„Zedd d
œdd„ƒZ	ddœdd„Z
eddœdd„ƒZejdd	dœdd„ƒZeddœdd„ƒZejdd	dœdd„ƒZeddœdd„ƒZdddœdd „Zed!d"�d	dœd#d$„ƒZed!d"�d%d	d&œd'd(„ƒZeZd)d*œd+d,d,d-œd.d/„Zd0d1d2œd3d4„Zdd5d6d7œd8d9„ZedRd;d<d=d>œd?d@„ƒZedSd;d,dAd>œdBd@„ƒZdTd;d,dAd>œdDd@„ZdUdEd,dFdGœdHdI„ZdJdœdKdL„ZdMdNdOœdPdQ„Z‡  ZS )Vrh   zoThe root of the collection tree.

    ``Session`` collects the initial paths given as arguments to pytest.
    r!   Z_setupstater$   Z_fixturemanagerr_   rg   r   r%   rƒ   c              	     sŽ   t ƒ jd|jd d || dd� d| _d| _d| _d| _|jj 	d¡| _t
ƒ | _t
ƒ | _g | _g | _i | _g | _t|jƒ| _| jjj| dd� d S )NrŽ   )rª   r9   Úfspathr«   r`   rc   r·   r   Fr8   rc   )rª   )rÌ   r¿   ZrootpathrŠ   r‹   Ú_shouldstopÚ_shouldfailÚtraceÚrootÚgetÚ	frozensetÚ_initialpathsÚ_initialpaths_with_parentsÚ	_notfoundÚ_initial_partsÚ_collection_cacher“   rÇ   Ú_bestrelpathcacher`   ÚpluginmanagerÚregister)r¾   r`   rÎ   rR   rS   r¿   2  s,    ù	zSession.__init__c                 C  s   | j |d�}|S )Nr†   )Ú_create)rÍ   r`   rc   rR   rR   rS   ri   L  s    zSession.from_configrO   rÐ   c              	   C  s4   d| j j› d| j› d| j› d| j› d�	t| ddƒ S )Nú<ú z exitstatus=%r testsfailed=z testscollected=ú>rg   z<UNSET>)rÏ   r|   rª   rŠ   r‹   Úgetattr©r¾   rR   rR   rS   Ú__repr__Q  s    þý
ûzSession.__repr__z
bool | strc                 C  s   | j S r„   )rÝ   rð   rR   rR   rS   r–   Y  s    zSession.shouldstop)rs   r'   c                 C  s.   |du r$| j r$tjtdƒdd� d S || _ d S )NFzCsession.shouldstop cannot be unset after it has been set; ignoring.rd   ©Ú
stacklevel)rÝ   ÚwarningsÚwarnr"   ©r¾   rs   rR   rR   rS   r–   ]  s    ÿüc                 C  s   | j S r„   )rÞ   rð   rR   rR   rS   r•   k  s    zSession.shouldfailc                 C  s.   |du r$| j r$tjtdƒdd� d S || _ d S )NFzCsession.shouldfail cannot be unset after it has been set; ignoring.rd   rò   )rÞ   rô   rõ   r"   rö   rR   rR   rS   r•   o  s    ÿür   c                 C  s
   | j jjS )zQThe path from which pytest was invoked.

        .. versionadded:: 7.0.0
        )r`   Úinvocation_paramsr:   rð   rR   rR   rS   r€   }  s    zSession.startpath)Ú	node_pathr'   c                 C  s
   | j | S r„   )rè   )r¾   rø   rR   rR   rS   Ú_node_location_to_relpath…  s    z!Session._node_location_to_relpathT)Ztryfirstc                 C  s(   | j r|  | j ¡‚| jr$|  | j¡‚d S r„   )r•   rl   r–   r‘   rð   rR   rR   rS   Úpytest_collectstart‰  s    zSession.pytest_collectstartzTestReport | CollectReport)Úreportr'   c                 C  sL   |j rHt|dƒsH|  jd7  _| j d¡}|rH| j|krHd| j› d�| _d S )NZwasxfailr*   r)   zstopping after z	 failures)ÚfailedÚhasattrrŠ   r`   Úgetvaluer•   )r¾   rû   r)   rR   rR   rS   Úpytest_runtest_logreport�  s
    z Session.pytest_runtest_logreportFrÑ   zstr | os.PathLike[str]rI   )r9   rÒ   r'   c                C  s2   t |tƒr|nt|ƒ}|r$|| jv S || jv S dS )a>  Is path an initial path?

        An initial path is a path explicitly given to pytest on the command
        line.

        :param with_parents:
            If set, also return True if the path is a parent of an initial path.

        .. versionchanged:: 8.0
            Added the ``with_parents`` parameter.
        N)rr   r   rä   rã   )r¾   r9   rÒ   Zpath_rR   rR   rS   rÖ   š  s    
zSession.isinitpathzos.PathLike[str]zpluggy.HookRelay)rÜ   r'   c                 C  sT   t |tƒr|nt|ƒ}| jj}| |¡}|j |¡}|rHtt||ƒƒ}n| jj	}|S r„   )
rr   r   r`   ré   Z_getconftestmodulesZ_conftest_pluginsÚ
differencer   r»   rk   )r¾   rÜ   r9   r¼   Zmy_conftestmodulesr½   ÚproxyrR   rR   rS   Úgethookproxy²  s    
zSession.gethookproxyz%dict[Path, Sequence[nodes.Collector]]zSequence[nodes.Collector])r9   Ú
path_cacher'   c                 C  sx   ||v r|| S |  ¡ rF|  |j¡}|j|| d�}|dur@|fnd}n&| ¡ rh|  |¡}|j|| d�}nd}|||< |S )z�Create a Collector for the given path.

        `path_cache` makes it so the same Collectors are returned for the same
        path.
        r´   NrR   rÓ   )r¯   r  r«   rµ   rš   r×   )r¾   r9   r  rÕ   rØ   rÙ   rR   rR   rS   Ú_collect_pathÃ  s    
ÿ
zSession._collect_path.zSequence[str] | NonezLiteral[True]zSequence[nodes.Item])rC   Úgenitemsr'   c                 C  s   d S r„   rR   ©r¾   rC   r  rR   rR   rS   rŒ   â  s    zSession.perform_collectz&Sequence[nodes.Item | nodes.Collector]c                 C  s   d S r„   rR   r  rR   rR   rS   rŒ   ç  s    Nc              	   C  sô  |du r| j j}|  d| |¡ | jj jd7  _| j j}g | _g | _i | _g | _	| j	}�zfg }g }|D ]P}t
| j jj|| j jjd�}| j |¡ | |j¡ | |j¡ | |jj¡ qft|ƒ| _t|ƒ| _t| ƒ}	| jj|	d� | jj jd8  _| j�rJg }
| jD ]:\}}|�r.|
 d|› d|›d�¡ n|
 d	|› �¡ �qt|
Ž ‚|�sX|	j}n(|	j�r€|	jD ]}| j	 |  |¡¡ �qf| j j ¡  |j| | j |d
� W g | _g | _i | _|j | d� n g | _g | _i | _|j | d� 0 |�rðt!|ƒ| _"|S )aƒ  Perform the collection phase for this session.

        This is called by the default :hook:`pytest_collection` hook
        implementation; see the documentation of this hook for more details.
        For testing purposes, it may also be called directly on a fresh
        ``Session``.

        This function normally recursively expands any collectors collected
        from the session to their items, and only items are returned. For
        testing purposes, this may be suppressed by passing ``genitems=False``,
        in which case the return value contains these collectors unexpanded,
        and ``session.items`` is empty.
        NrŒ   r*   ©Ú	as_pypath©rû   znot found: z
(no match in any of ú)zfound no collectors for )rc   r`   r“   rb   )#r`   rC   rß   rà   Úindentrk   rå   ræ   rç   r“   Úresolve_collection_argumentr÷   r:   r{   Zpyargsr5   r9   r­   rX   râ   rã   rä   r    rÕ   Úpytest_collectreportr   ÚresultÚpassedr  ré   Zcheck_pendingrº   Zpytest_collection_finishr”   r‹   )r¾   rC   r  rk   r“   ZinitialpathsZinitialpaths_with_parentsÚargÚcollection_argumentÚrepÚerrorsZ
collectorsÚnoderR   rR   rS   rŒ   ì  sr    ý

ÿ
ÿý
r±   ztuple[CollectReport, bool])r  Úhandle_dupesr'   c                 C  s>   || j v r |r | j | }|dfS t|ƒ}|| j |< |dfS d S )NTF)rç   r    )r¾   r  r  r  rR   rR   rS   Ú_collect_one_node>  s    

zSession._collect_one_nodez&Iterator[nodes.Item | nodes.Collector]c                 c  sô  i }| j j}| jD �]Ú}|  d|¡ | jj jd7  _|j}|j}|j}| 	¡ rf|rfJ d||f›�ƒ‚|g}|d u rœ|j
D ]}| |¡sŒ qè| d|¡ qznL| d¡}	t|j
dƒD ]4\}
}|
t|	ƒksÖ|j|	|
  krÚ qè| d|¡ q²d}g }| g |¢|¢fg}|�r°| ¡ \}}|�s(|V  d}�qt|tjƒ�s:�qt|tƒ�rlt|d tƒ�sZJ ‚| |d |¡}njt|ƒdk�o”t|d tƒ�o”|d  ¡  }|  ||¡\}}|�sÄ|j�sÄ|jj|d	� |j�sÐ�q|j}d}t|ƒD ]¸}t|d tƒ�rP|j|d k}tj d
k�rx|�sxt!j "|j|d ¡}|�oLt!j #|j¡t!j #|d ¡k}n(|j$|d k�pv|j$ d¡d |d k}|�râ| %||dd … f¡ d}�qâ|�s| %|¡ �q|�sÜd &t'|ƒg|¢R ¡}| j( %||f¡ | jj jd8  _qd S )Nzprocessing argumentr*   zinvalid arg r   Ú.rd   FTr	  Úwin32ú[ú::))r`   ré   ræ   rß   rà   r  r9   ÚpartsÚmodule_namer¯   rX   Z_is_in_confcutdirÚinsertÚsplitr’   r”   ÚstemÚpoprr   r   Ú	Collectorrh   r   r  rš   r  r  rÕ   r  r  Úreversedru   Úplatformr~   ÚsamefileÚislinkrª   r5   ÚjoinrO   rå   )r¾   r  r¼   r  ZargpathÚnamesr  Úpathsr9   Zmodule_name_partsr—   Zany_matched_in_initial_partZnotfound_collectorsZworkZ	matchnodeZ
matchpartsZsubnodesr  r  Ú	duplicateZany_matched_in_collectorr  Zis_matchZ	same_fileZ
report_argrR   rR   rS   r7   K  sŒ    


ÿÿ
ýÿÿ
þzSession.collectznodes.Item | nodes.CollectorzIterator[nodes.Item])r  r'   c                 c  s°   |   d|¡ t|tjƒr.|jj|d� |V  n~t|tjƒs>J ‚| j d¡}|oXt|tj	ƒ }|  
||¡\}}|rx|sxd S |jrš|jD ]}|  |¡E d H  q„|s¬|jj|d� d S )Nr  )r�   r<   r	  )rß   rr   r   ZItemrÕ   Zpytest_itemcollectedr!  r`   r¬   ÚFiler  r  r  r  r  )r¾   r  r<   r  r  r)  ZsubnoderR   rR   rS   r  Ä  s    
zSession.genitems)..)..)NT)T)r|   rÂ   rÃ   rÆ   r‘   rl   rË   r¿   rÚ   ri   rñ   Úpropertyr–   Úsetterr•   r€   rù   r   rú   rÿ   r  rÖ   r  r  r   rŒ   r  r7   r  rÛ   rR   rR   rÎ   rS   rh   #  sT   
ü ÿ ÿ ÿU ýyú
str | None)r  r'   c              
   C  sj   zt j | ¡}W n tttfy*   Y dS 0 |du sH|jdu sH|jdkrLdS |jr`tj	 
|j¡S |jS dS )zaSearch sys.path for the given a dotted module name, and return its file
    system path if found.NÚ	namespace)r@   ÚutilÚ	find_specÚAttributeErrorÚImportErrorÚ
ValueErrorÚoriginÚsubmodule_search_locationsr~   r9   Údirname)r  ÚspecrR   rR   rS   Úsearch_pypathØ  s    r8  T)Úfrozenc                   @  s*   e Zd ZU dZded< ded< ded< dS )	ÚCollectionArgumentzA resolved collection argument.r   r9   zSequence[str]r  r-  r  N)r|   rÂ   rÃ   rÆ   rË   rR   rR   rR   rS   r:  ê  s   
r:  Fr  )Úinvocation_pathr  r  r'   c                C  sÈ   t |ƒ d¡\}}}| d¡^}}|r>|d › |› |› �|d< d}|r^t|ƒ}	|	dur^|}|	}| | }
t|
ƒ}
t|
ƒs’|r~dnd}t|j|d�ƒ‚|rº|
 ¡ rº|r¦dnd	}t|j|d�ƒ‚t	|
||d
�S )aÃ  Parse path arguments optionally containing selection parts and return (fspath, names).

    Command-line arguments can point to files and/or directories, and optionally contain
    parts for specific tests selection, for example:

        "pkg/tests/test_foo.py::TestClass::test_foo"

    This function ensures the path exists, and returns a resolved `CollectionArgument`:

        CollectionArgument(
            path=Path("/full/path/to/pkg/tests/test_foo.py"),
            parts=["TestClass", "test_foo"],
            module_name=None,
        )

    When as_pypath is True, expects that the command-line argument actually contains
    module paths instead of file-system paths:

        "pkg.tests.test_foo::TestClass::test_foo"

    In which case we search sys.path for a matching module, and then return the *path* to the
    found module, which may look like this:

        CollectionArgument(
            path=Path("/home/u/myvenv/lib/site-packages/pkg/tests/test_foo.py"),
            parts=["TestClass", "test_foo"],
            module_name="pkg.tests.test_foo",
        )

    If the path doesn't exist, raise UsageError.
    If the path is a directory and selection parts are present, raise UsageError.
    r  r  éÿÿÿÿNz9module or package not found: {arg} (missing __init__.py?)z"file or directory not found: {arg})r  z9package argument cannot contain :: selection parts: {arg}z;directory argument cannot contain :: selection parts: {arg})r9   r  r  )
rO   Ú	partitionr  r8  r   r   r   Úformatr¯   r:  )r;  r  r  rV   ZsquacketÚrestZstrpathr  r  Zpyarg_strpathrÜ   r^   rR   rR   rS   r  ó  s:    #ÿýÿýýr  )XrÆ   Ú
__future__r   rZ   Úcollections.abcr   r   r   r   r   ÚAbstractSetÚdataclassesr¦   rM   r@   Úimportlib.utilr~   Úpathlibr   ru   Útypingr	   r
   r   r   rô   Zpluggyrp   r   Z_pytest._codeZ_pytest.configr   r   r   r   r   r   Z_pytest.config.argparsingr   Z_pytest.config.compatr   Z_pytest.outcomesr   Z_pytest.pathlibr   r   r   r   r   Z_pytest.reportsr   r   Z_pytest.runnerr    r!   Z_pytest.warning_typesr"   Ztyping_extensionsr#   Z_pytest.fixturesr$   rT   rP   r‚   r‡   r…   rˆ   r‰   r�   r°   rµ   rº   r»   rn   r‘   ro   rl   Ú	dataclassÚdictrO   rÇ   Z	Directoryr²   r!  rh   r8  r:  r  rR   rR   rR   rS   Ú<module>   s”    D;&3   7
	ÿ