a
    ˆÏ?e’  ã                   @   sp  d Z ddlZddlZddlZddlZddlZddl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ZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl*m,Z, ddl*m-Z- ddl*m.Z. dd l*m/Z/ dd!l0m1Z1 dd"l0m2Z2 dd#l3m4Z4 dd$l3m5Z5 e�rîdd%l6m7Z7 e%dd&œd'd(„Z8e9e9d)œd*d+„Z:eeed,geee;e f  f ee;e f d-œd.d/„Z<eee;e f d0œd1d2„Z=ed,eee;e f  d3œd4d5„Z>d,dd6œd7d8„Z?d,e@d6œd9d:„ZAe	e@d)œd;d<„ZBe	eee@ d=œd>d?„ZCeejD edd@œdAdB„ZEG dCdD„ dDƒZFG dEdF„ dFeGƒZHG dGdH„ dHeIƒZJejKG dIdJ„ dJee	e9f ƒƒZLeG dKd,„ d,ejMƒƒZNe9e9dLœdMdN„ZOdOdPœe	e9e@ee	ee9 f dQœdRdS„ZPdS )TzHCore implementation of the testing process: init, session, runtest loop.é    N)ÚPath)ÚCallable)ÚDict)Ú	FrozenSet)ÚIterator)ÚList)ÚOptional)ÚSequence)ÚSet)ÚTuple)ÚType)ÚTYPE_CHECKING)ÚUnion)Únodes)Úfinal)Úoverload)ÚConfig)Údirectory_arg)ÚExitCode)Úhookimpl)ÚPytestPluginManager)Ú
UsageError)ÚParser)ÚFixtureManager)Úexit©Úabsolutepath)Úbestrelpath©Ú
fnmatch_ex)Úsafe_exists)Úvisit)ÚCollectReport)Ú
TestReport)Úcollect_one_node)Ú
SetupState)ÚLiteral)ÚparserÚreturnc              	   C   sü  | j dddg d¢d� | j dddg d� |  dd	¡}|jd
dddddd� |  d¡}|jddddd� | j 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� |jd(d)d*td+d,d-� |jd.d"d/d0d1d2� |jd3dd4d5d6� |  d7d8¡}|jd9d:d;d"d<d� |jd=d"d>d� |jd?dd@dAdB� |jdCdd@dDdB� |jdEddFdGdB� |jdHdId dJtjtdHdK�dLdM� |jdNd"dOd/dPdQ� |jdRdSd"dTd/dUdQ� |jdVd"dWd/dXdQ� |jdYdZg d[¢d\d]d^� |  d_d`¡}|jdadbd t	dJdcdd� d S )eNÚnorecursedirsz)Directory patterns to avoid for recursionÚargs)	z*.eggz.*Ú_darcsÚbuildÚCVSÚdistZnode_modulesÚvenvz{arch})ÚtypeÚdefaultZ	testpathszZDirectories to search for tests when no files or directories are given on the command lineZgeneralzRunning and selection optionsz-xz--exitfirstÚstore_constÚmaxfailé   z,Exit instantly on first error or failed test)ÚactionÚdestÚconstÚhelpzpytest-warningsz-Wz--pythonwarningsÚappendz<Set which warnings to report, see -W option of Python itself)r5   r8   ÚfilterwarningsZlinelistz_Each line specifies a pattern for warnings.filterwarnings. Processed after -W/--pythonwarnings.)r0   r8   z	--maxfailÚnumÚstorer   z'Exit after first num failures or errors)Úmetavarr5   r0   r6   r1   r8   z--strict-configÚ
store_truezbAny warnings encountered while parsing the `pytest` section of the configuration file raise errorsz--strict-markerszVMarkers not registered in the `markers` section of the configuration file raise errorsz--strictz&(Deprecated) alias to --strict-markersz-cz--config-fileÚFILEZinifilenamezcLoad configuration from `FILE` instead of trying to locate one of the implicit configuration files.)r=   r0   r6   r8   z--continue-on-collection-errorsFÚcontinue_on_collection_errorsz4Force test execution even if collection errors occur)r5   r1   r6   r8   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'.)r5   r6   r8   Ú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))r5   r=   r8   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)r6   r1   r=   r0   r8   z--noconftestZ
noconftestz Don't load any conftest.py files)r5   r6   r1   r8   z--keepduplicatesz--keep-duplicatesÚkeepduplicateszKeep duplicate testsz--collect-in-virtualenvÚcollect_in_virtualenvz2Don't ignore tests in a local virtualenv directoryz--import-modeÚprepend)rI   r9   Ú	importlibÚ
importmodez\Prepend/append to sys.path when importing test modules and conftest files. Default: prepend.)r1   Úchoicesr6   r8   Zdebugconfigz(test session debugging and configurationz
--basetempZbasetempz^Base temporary directory for this test run. (Warning: this directory is removed if it exists.))r6   r1   r0   r=   r8   )
ZaddiniZgetgroupZ
_addoptionZ	addoptionÚintÚstrÚ	functoolsÚpartialr   Úvalidate_basetemp)r'   Úgroup© rS   úO/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/_pytest/main.pyÚpytest_addoption3   s6   üûú
üýù	ýýýú	ûü	ûýüüüúûúûû	ùrU   ©rD   r(   c                 C   sl   d}| st  |¡‚tttdœdd„}|t ¡ t| ƒ ¡ ƒrDt  |¡‚|t ¡  ¡ t| ƒ ¡ ƒrht  |¡‚| S )NzWbasetemp must not be empty, the current working directory or any parent directory of it)ÚbaseÚqueryr(   c                 S   s   | |krdS || j v S )z,Return whether query is an ancestor of base.T)Úparents)rW   rX   rS   rS   rT   Úis_ancestorñ   s    z&validate_basetemp.<locals>.is_ancestor)ÚargparseÚArgumentTypeErrorr   ÚboolÚcwdÚabsoluteÚresolve)rD   ÚmsgrZ   rS   rS   rT   rQ   é   s    


rQ   ÚSession)Ú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   r4   ©Úsessioné   Nz: Ú
)Úexcinfoz(mainloop: caught unexpected SystemExit!
)rf   Ú
exitstatus))rb   Úfrom_configr   ÚOKrj   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Útypenamera   Zpytest_keyboard_interruptÚBaseExceptionÚINTERNAL_ERRORZnotify_exceptionÚoptionr0   Ú__name__Ú
SystemExitÚosÚchdirÚ	startpathZpytest_sessionfinishZ_ensure_unconfigure)rc   rd   rf   Z	initstateri   rj   ÚexcrS   rS   rT   Úwrap_session  sz    

4
ÿ
4
õ
ÿ
4
r„   ©rc   r(   c                 C   s
   t | tƒS ©N)r„   Ú_main©rc   rS   rS   rT   Úpytest_cmdline_main=  s    r‰   )rc   rf   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.re   r   N)rm   Úpytest_collectionÚpytest_runtestloopÚtestsfailedr   ro   ÚtestscollectedZNO_TESTS_COLLECTED)rc   rf   rS   rS   rT   r‡   A  s    
r‡   )rf   r(   c                 C   s   |   ¡  d S r†   )Úperform_collectre   rS   rS   rT   rŠ   N  s    rŠ   c                 C   s²   | j r2| jjjs2|  d| j | j dkr(dndf ¡‚| jjjr@dS t| jƒD ]b\}}|d t| jƒk rr| j|d  nd }|jj	j
||d� | jrš|  | j¡‚| jrJ|  | j¡‚qJdS )Nz%d error%s during collectionr4   ÚsÚ T)ÚitemÚnextitem)rŒ   rc   r}   r@   ÚInterruptedZcollectonlyÚ	enumerateÚitemsÚlenrm   Zpytest_runtest_protocolÚ
shouldfailrn   Ú
shouldstop)rf   Úir‘   r’   rS   rS   rT   r‹   R  s     ÿÿ
$r‹   c                    s`   |   tj d¡rdnd¡}z| ¡ s*W dS W n ty@   Y dS 0 d‰ t‡ fdd„| ¡ D ƒƒS )zˆAttempt to detect if ``path`` is the root of a Virtual Environment by
    checking for the existence of the appropriate activate script.ÚwinZScriptsÚbinF)Úactivatezactivate.cshzactivate.fishZActivatezActivate.batzActivate.ps1c                 3   s   | ]}|j ˆ v V  qd S r†   ©Úname)Ú.0Úfname©Z	activatesrS   rT   Ú	<genexpr>w  ó    z_in_venv.<locals>.<genexpr>)Újoinpathrw   ÚplatformÚ
startswithÚis_dirÚOSErrorÚanyÚiterdir)rD   ZbindirrS   r¡   rT   Ú_in_venvf  s    
r«   )Úcollection_pathrc   r(   c                    sì   |j dˆ j|jd�}|pg }| d¡}|r>| dd„ |D ƒ¡ ˆ |v rJdS |j dˆ j|jd�}|pdg }| 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 )NZcollect_ignore)rD   ÚrootpathÚignorec                 s   s   | ]}t |ƒV  qd S r†   r   ©rŸ   ÚxrS   rS   rT   r¢   �  r£   z(pytest_ignore_collect.<locals>.<genexpr>TZcollect_ignore_globZignore_globc                 s   s   | ]}t |ƒV  qd S r†   r   r¯   rS   rS   rT   r¢   Œ  r£   c                 3   s"   | ]}t   tˆ ƒt|ƒ¡V  qd S r†   )ÚfnmatchrN   )rŸ   Úglob©r¬   rS   rT   r¢   Ž  r£   rH   r)   c                 3   s   | ]}t |ˆ ƒV  qd S r†   r   )rŸ   Úpatr³   rS   rT   r¢   —  r£   )	Z_getconftest_pathlistÚparentr­   Ú	getoptionÚextendr©   r«   r§   Zgetini)r¬   rc   Zignore_pathsZ
excludeoptZignore_globsZexcludegloboptZallow_in_venvZnorecursepatternsrS   r³   rT   Úpytest_ignore_collectz  s4    
ÿ

ÿ


r¸   )r•   rc   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¶   Únodeidr¦   r9   rm   Zpytest_deselected)r•   rc   Zdeselect_prefixesÚ	remainingZ
deselectedZcolitemrS   rS   rT   Úpytest_collection_modifyitems�  s    r¼   c                   @   s*   e Zd Zeddœdd„Zedœdd„ZdS )ÚFSHookProxyN)Úpmr(   c                 C   s   || _ || _d S r†   )r¾   Úremove_mods)Úselfr¾   r¿   rS   rS   rT   Ú__init__°  s    zFSHookProxy.__init__r�   c                 C   s    | j j|| jd�}|| j|< |S )N)Zremove_plugins)r¾   Zsubset_hook_callerr¿   Ú__dict__)rÀ   rž   r°   rS   rS   rT   Ú__getattr__´  s    
zFSHookProxy.__getattr__)r~   Ú
__module__Ú__qualname__r   rÁ   rN   rÃ   rS   rS   rS   rT   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__rS   rS   rS   rT   r“   º  s   r“   c                   @   s   e Zd ZdZdS )rn   z"Signals a stop as failed test run.NrÇ   rS   rS   rS   rT   rn   À  s   rn   c                   @   s*   e Zd ZU dZeed< eedœdd„ZdS )Ú_bestrelpath_cache)rD   rD   rV   c                 C   s   t | j|ƒ}|| |< |S r†   )r   rD   )rÀ   rD   ÚrrS   rS   rT   Ú__missing__Ê  s    z_bestrelpath_cache.__missing__N)r~   rÄ   rÅ   Ú	__slots__r   Ú__annotations__rN   rË   rS   rS   rS   rT   rÉ   Ä  s   
rÉ   c                       sæ  e Zd ZU dZeZeZeed< eed< e	e
ef ed< eddœ‡ fdd„Zeed dœd	d
„ƒZedœdd„Zeedœdd„ƒZeedœdd„Zedd�ddœdd„ƒZedd�e	eef ddœdd„ƒZeZe	edf edœdd„Zddœdd „Zd!ed"œd#d$„Zd4eee e!j" d%œd&d'„Z#e$d5e%e e  d)e e!j& d*œd+d,„ƒZ'e$d6e%e e  ee e	e!j&e!j"f  d*œd-d,„ƒZ'd7e%e e  ee e	e!j&e!j"f  d*œd.d,„Z'e(e	e!j&e!j"f  dœd/d0„Z)e	e!j&e!j"f e(e!j& d1œd2d3„Z*‡  Z+S )8rb   zoThe root of the collection tree.

    ``Session`` collects the initial paths given as arguments to pytest.
    Z_setupstateZ_fixturemanagerrj   Nr…   c                    sl   t ƒ j|jd d || dd� d| _d| _d| _d| _|jj 	d¡| _t
ƒ | _t|jƒ| _| jjj| dd� d S )Nr�   )rD   Úfspathrµ   rc   rf   rº   r   FrC   rf   r�   )ÚsuperrÁ   r­   rŒ   r�   r˜   r—   ÚtraceÚrootÚgetÚ	frozensetÚ_initialpathsrÉ   Ú_bestrelpathcacherc   ÚpluginmanagerÚregister)rÀ   rc   ©Ú	__class__rS   rT   rÁ   ß  s     úzSession.__init__c                 C   s   | j |d�}|S )Nrˆ   )Ú_create)Úclsrc   rf   rS   rS   rT   rk   ó  s    zSession.from_config)r(   c                 C   s$   d| j j| jt| ddƒ| j| jf S )Nz6<%s %s exitstatus=%r testsfailed=%d testscollected=%d>rj   z<UNSET>)rÙ   r~   rž   ÚgetattrrŒ   r�   ©rÀ   rS   rS   rT   Ú__repr__ø  s    
ûzSession.__repr__c                 C   s
   | j jjS )zQThe path from which pytest was invoked.

        .. versionadded:: 7.0.0
        )rc   Úinvocation_paramsrE   rÝ   rS   rS   rT   r‚     s    zSession.startpath)Ú	node_pathr(   c                 C   s
   | j | S r†   )rÕ   )rÀ   rà   rS   rS   rT   Ú_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—   rn   r˜   r“   rÝ   rS   rS   rT   Úpytest_collectstart  s    zSession.pytest_collectstart)Úreportr(   c                 C   sH   |j rDt|dƒsD|  jd7  _| j d¡}|rD| j|krDd| j | _d S )NZwasxfailr4   r3   zstopping after %d failures)ÚfailedÚhasattrrŒ   rc   Úgetvaluer—   )rÀ   rã   r3   rS   rS   rT   Úpytest_runtest_logreport  s
    z Session.pytest_runtest_logreportzos.PathLike[str]rV   c                 C   s    t |tƒr|nt|ƒ}|| jv S r†   )rt   r   rÔ   )rÀ   rD   Zpath_rS   rS   rT   Ú
isinitpath   s    zSession.isinitpath)rÎ   c                 C   sr   t |tƒr|nt|ƒ}| jj}|j|| j d¡| jjd�}|j |¡}|rfddl	m
} |t||ƒƒ}n| jj}|S )NrK   )r­   r4   )ÚPathAwareHookProxy)rt   r   rc   rÖ   Z_getconftestmodulesr¶   r­   Z_conftest_pluginsÚ
differenceZconfig.compatré   r½   rm   )rÀ   rÎ   rD   r¾   Zmy_conftestmodulesr¿   ré   ÚproxyrS   rS   rT   Úgethookproxy%  s    
ýzSession.gethookproxyzos.DirEntry[str])Údirentryr(   c                 C   s<   |j dkrdS t|jƒ}|  |j¡}|j|| jd�r8dS dS )NÚ__pycache__F©r¬   rc   T)rž   r   rD   rì   rµ   r¸   rc   )rÀ   rí   rÎ   ÚihookrS   rS   rT   Ú_recurse;  s    

zSession._recurse)rÎ   Úhandle_dupesr(   c                 C   s’   |  ¡ s(J d || ¡ | ¡ | ¡ ¡ƒ‚|  |¡}|  |¡sP|j|| jd�rPdS |r„| j 	d¡}|s„| jj
j}||v rzdS | |¡ |j|| d�S )Nz9{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})rï   rS   rG   )Ú	file_pathrµ   )Úis_fileÚformatr§   ÚexistsÚ
is_symlinkrì   rè   r¸   rc   r¶   rÖ   Z_duplicatepathsÚaddZpytest_collect_file)rÀ   rÎ   rò   rð   rG   Zduplicate_pathsrS   rS   rT   Ú_collectfileD  s$    ÿÿþ



zSession._collectfile.zLiteral[True])r*   Úgenitemsr(   c                 C   s   d S r†   rS   ©rÀ   r*   rú   rS   rS   rT   rŽ   \  s    zSession.perform_collectc                 C   s   d S r†   rS   rû   rS   rS   rT   rŽ   b  s    c              
   C   s¦  |du r| j j}|  d| |¡ | jj jd7  _g | _g | _g | _| j j}| j}�z6g }|D ]<}t	| j j
j|| j jjd�\}}| j ||f¡ | |¡ q\t|ƒ| _t| ƒ}	| jj|	d� | jj jd8  _| j�r&g }
| jD ]>\}}|�r|
 d|› d|›d|›d	�¡ qÞ|
 d
|› �¡ qÞt|
Ž ‚|�s4|	j}n(|	j�r\|	jD ]}| j |  |¡¡ �qB| j j ¡  |j| | j |d� W |j| d� n|j| d� 0 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Ž   r4   ©Ú	as_pypath©rã   znot found: z

(no name z in any of ú)zfound no collectors for )rf   rc   r•   re   )rc   r*   rÐ   rÑ   ÚindentÚ	_notfoundÚ_initial_partsr•   rm   Úresolve_collection_argumentrß   rE   r}   Zpyargsr9   rÓ   rÔ   r$   rð   Úpytest_collectreportr   ÚresultÚpassedr·   rú   rÖ   Zcheck_pendingr¼   Zpytest_collection_finishr–   r�   )rÀ   r*   rú   rm   r•   ZinitialpathsÚargrÎ   ÚpartsÚrepÚerrorsZ
collectorsÚnoderS   rS   rT   rŽ   h  sX    ý

ÿ
ÿ
c              	   c   s  ddl m} i }i }i }i }| jD �]î\}}|  d||f¡ | jj jd7  _| j dd¡sæ| jj}|g|j	¢R D ]r}	| 
|¡s„ qæ|	 ¡ rr|	d }
|
 ¡ rr|
|vrr| j|
dd�}|rrt|d |ƒrÐ|d ||	< |d g||d j< qr| ¡ �rè|�rJ d	||f›�ƒ‚tƒ }t|| jƒD ]È}| ¡ �s,�qt|jƒ}|j}||v�rŽ| |¡ |d }
|
 ¡ �rŽ|  |
¡D ] }|V  t||ƒ�rl|||< �ql||v �rœ�q|  |¡D ]8}t|ƒ|jf}||v �rÎ|| V  n|||< |V  �q¦�q�n| ¡ �söJ ‚||v �r
|| }n*| |j| ¡}|j|dd�}|�r4|||< g }||fg}|�rz|  d
||¡ | jj jd7  _| ¡ \}}|D ]Ø}|�s�| |¡ �qxt|tjƒ�s¢�qxt|ƒ|jf}||v �rÄ|| }nt|ƒ}|||< |j�r@g }|j D ]:}|j!|d k�s|j! "d¡d |d k�ræ| |¡ �qæ|�rN| ||dd … f¡ n|j#j$|d� �qx|  dt%|ƒd¡ | jj jd8  _�qB|�s¨d &t'|ƒg|¢R ¡}| j( ||f¡ q"|j!dk�röt|d |ƒ�rözt)t*|d  +¡ ƒƒV  W q" t,�yò   Y q"0 q"|E d H  | jj jd8  _q"d S )Nr   )ÚPackagezprocessing argumentr4   ZdoctestmodulesFz__init__.py)rò   zinvalid arg Ú
matchnodesú[rþ   zmatchnodes finished -> r   ú::)-Z_pytest.pythonr  r  rÐ   rÑ   r   rc   r¶   rÖ   rY   Z_is_in_confcutdirr§   rô   rù   rt   rD   Úsetr!   rñ   r   rµ   rø   rö   r0   rÒ   Úpopr9   r   Ú	Collectorrº   r$   r  r  rž   Úsplitrð   r  r–   ÚjoinrN   r  ÚnextÚiterrB   ÚStopIteration)rÀ   r  Znode_cache1Znode_cache2Zmatchnodes_cacheZ	pkg_rootsZargpathÚnamesr¾   rµ   ZpkginitÚcolZ	seen_dirsrí   rD   Údirpathr°   Úkey2Zcollect_rootZmatchingZworkr  Z
matchnamesr  Úkeyr	  ZsubmatchnodesrÊ   Z
report_argrS   rS   rT   rB   ¯  s¾    










þ



ÿþ
zSession.collect)r  r(   c                 c   sz   |   d|¡ t|tjƒr.|jj|d� |V  nHt|tjƒs>J ‚t|ƒ}|jrh|j	D ]}|  
|¡E d H  qR|jj|d� d S )Nrú   )r‘   rþ   )rÐ   rt   r   ÚItemrð   Zpytest_itemcollectedr  r$   r  r  rú   r  )rÀ   r  r	  ZsubnoderS   rS   rT   rú   A  s    
zSession.genitems)T)..)..)NT),r~   rÄ   rÅ   rÈ   r“   rn   r%   rÍ   r   r   rM   r   r   rÁ   Úclassmethodrk   rN   rÞ   Úpropertyr   r‚   rá   r   râ   r#   r"   rç   r  r]   rè   rì   rñ   r	   r   r  rù   r   r   r  rŽ   r   rB   rú   Ú__classcell__rS   rS   rØ   rT   rb   Ð  sd   
	
þ	
 ÿþ ÿþ ÿþ ÿþG þ)Úmodule_namer(   c              
   C   sl   zt j | ¡}W n tttfy,   |  Y S 0 |du sJ|jdu sJ|jdkrN| S |jrbtj	 
|j¡S |jS dS )zTSearch sys.path for the given a dotted module name, and return its file system path.NÚ	namespace)rJ   ÚutilÚ	find_specÚAttributeErrorÚImportErrorÚ
ValueErrorÚoriginÚsubmodule_search_locationsr€   rD   Údirname)r!  ÚspecrS   rS   rT   Úsearch_pypathQ  s    
r,  Frü   )Úinvocation_pathr  rý   r(   c          
      C   s®   t |ƒ d¡\}}}| d¡^}}|r>|d › |› |› �|d< |rJt|ƒ}| | }t|ƒ}t|ƒs~|rjdnd}	t|	j|d�ƒ‚|r¦| ¡ r¦|r’dnd}	t|	j|d�ƒ‚||f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 tuple:

        (Path("/full/path/to/pkg/tests/test_foo.py"), ["TestClass", "test_foo"])

    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.

    If the path doesn't exist, raise UsageError.
    If the path is a directory and selection parts are present, raise UsageError.
    r  r  éÿÿÿÿz9module 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})	rN   Ú	partitionr  r,  r   r    r   rõ   r§   )
r-  r  rý   rW   ZsquacketÚrestZstrpathr  rÎ   ra   rS   rS   rT   r  b  s*    ÿýÿýr  )QrÈ   r[   Zdataclassesr±   rO   rJ   r€   rw   Úpathlibr   Útypingr   r   r   r   r   r   r	   r
   r   r   r   r   Z_pytest._coderr   r   Z_pytest.compatr   r   Z_pytest.configr   r   r   r   r   r   Z_pytest.config.argparsingr   Z_pytest.fixturesr   Z_pytest.outcomesr   Z_pytest.pathlibr   r   r   r    r!   Z_pytest.reportsr"   r#   Z_pytest.runnerr$   r%   Ztyping_extensionsr&   rU   rN   rQ   rM   r„   r‰   r‡   rŠ   r]   r‹   r«   r¸   r  r¼   r½   rp   r“   rq   rn   Z	dataclassrÉ   ZFSCollectorrb   r,  r  rS   rS   rS   rT   Ú<module>   s’    7
þ;#   ÿþ