o
    Ú­j!B  ã                	   @   sÒ  d 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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+ e	r¶ddl,m-Z- ddl.Z.eG dd„ dƒƒZ/G d d!„ d!ƒZ0eej1G d"d#„ d#ƒƒƒZ2G d$d%„ d%ƒZ3d&ed'e4d(efd)d*„Z5d&ed(efd+d,„Z6d&e)d(efd-d.„Z7d&ed(efd/d0„Z8d&ed(efd1d2„Z9d&ed(ee fd3d4„Z:d&ed(efd5d6„Z;d'e4d7e4d8e
e4ee4 f fd9d:„Z<d&e#d(efd;d<„Z=d&e#d8ed(dfd=d>„Z>ed?d@�dAed(dfdBdC„ƒZ?edDed(dfdEdF„ƒZ@edGeAdHed(dfdIdJ„ƒZBdS )Kz?Add backward compatibility support for the legacy py path type.é    N)ÚPath)ÚList)ÚOptional)ÚTYPE_CHECKING)ÚUnion)ÚSectionWrapper)ÚCache)Úfinal)ÚLEGACY_PATH©Úlegacy_path)ÚConfig)Úhookimpl)ÚPytestPluginManager)Úcheck_ispytest)Úfixture)ÚFixtureRequest)ÚSession)ÚMonkeyPatch)Ú	Collector)ÚItem)ÚNode)ÚHookRecorder)ÚPytester)Ú	RunResult)ÚTerminalReporter)ÚTempPathFactory)ÚFinalc                	   @   sø  e Zd ZU dZdZejZded< ejZded< ddœdede	d	d
fdd„Z
ed	efdd„ƒZed	efdd„ƒZedd„ ƒZedd„ ƒZejdd„ ƒZed	efdd„ƒZd	efdd„Zdtdd„Zdtdd„Zd	efdd„Zd	efd d!„Zd	efd"d#„Zd$ed	efd%d&„Zd	efd'd(„Zd	efd)d*„Zd	efd+d,„Z dudtd-d.„Z!d	efd/d0„Z"d	efd1d2„Z#dud	efd3d4„Z$d5e%d	e&e'e(e)f  fd6d7„Z*d8d9„ Z+d:e,e'e(e)f  d	e,e( fd;d<„Z-d=d>„ Z.d?d@„ Z/dAdB„ Z0dCddDœdEe	fdFdG„Z1d	e2fdHdI„Z3d	e2fdJdK„Z4d	e%fdLdM„Z5d	e%fdNdO„Z6dvdQdR„Z7dSdT„ Z8dwdUdV„Z9dWe)dXed	e&e'e(e)f  fdYdZ„Z:e;j<e;j<efd[d\„Z=d
ed]œd	e2fd^d_„Z>d	e2fd`da„Z?dbdc„ Z@d
ddœd	e2fdedf„ZA	gdxdhedieBd	djfdkdl„ZCdxdmedieBd	djfdndo„ZDd	efdpdq„ZEd	efdrds„ZFd
S )yÚTestdirzì
    Similar to :class:`Pytester`, but this class works with legacy legacy_path objects instead.

    All methods just forward to an internal :class:`Pytester` instance, converting results
    to `legacy_path` objects as necessary.
    Fr   ÚCLOSE_STDINÚTimeoutExpired©Ú	_ispytestÚpytesterr"   ÚreturnNc                C   ó   t |ƒ || _d S ©N)r   Ú	_pytester)Úselfr#   r"   © r)   úO/var/www/html/CropPilot/venv/lib/python3.10/site-packages/_pytest/legacypath.pyÚ__init__6   s   
zTestdir.__init__c                 C   ó   t | jjƒS )z-Temporary directory where tests are executed.)r   r'   Úpath©r(   r)   r)   r*   Útmpdir:   s   zTestdir.tmpdirc                 C   r,   r&   )r   r'   Ú_test_tmprootr.   r)   r)   r*   Útest_tmproot?   ó   zTestdir.test_tmprootc                 C   ó   | j jS r&   )r'   Ú_requestr.   r)   r)   r*   ÚrequestC   ó   zTestdir.requestc                 C   r3   r&   ©r'   Úpluginsr.   r)   r)   r*   r8   G   r6   zTestdir.pluginsc                 C   s   || j _d S r&   r7   )r(   r8   r)   r)   r*   r8   K   r2   c                 C   r3   r&   )r'   Ú_monkeypatchr.   r)   r)   r*   ÚmonkeypatchO   r6   zTestdir.monkeypatchc                 C   ó   | j  |¡S )z(See :meth:`Pytester.make_hook_recorder`.)r'   Úmake_hook_recorder)r(   Úpluginmanagerr)   r)   r*   r<   S   r2   zTestdir.make_hook_recorderc                 C   ó
   | j  ¡ S )zSee :meth:`Pytester.chdir`.)r'   Úchdirr.   r)   r)   r*   r?   W   ó   
zTestdir.chdirc                 C   r>   )zSee :meth:`Pytester._finalize`.)r'   Ú	_finalizer.   r)   r)   r*   Úfinalize[   r@   zTestdir.finalizec                 O   s4   |r|  d¡sd| }t| jj|g|¢R i |¤ŽƒS )zSee :meth:`Pytester.makefile`.Ú.)Ú
startswithr   r'   Úmakefile)r(   ÚextÚargsÚkwargsr)   r)   r*   rE   _   s   zTestdir.makefilec                 C   ó   t | j |¡ƒS )z"See :meth:`Pytester.makeconftest`.)r   r'   Úmakeconftest©r(   Úsourcer)   r)   r*   rJ   k   ó   zTestdir.makeconftestc                 C   rI   )zSee :meth:`Pytester.makeini`.)r   r'   ÚmakeinirK   r)   r)   r*   rN   o   rM   zTestdir.makeinirL   c                 C   r;   )zSee :meth:`Pytester.getinicfg`.)r'   Ú	getinicfgrK   r)   r)   r*   rO   s   r2   zTestdir.getinicfgc                 C   rI   )z'See :meth:`Pytester.makepyprojecttoml`.)r   r'   ÚmakepyprojecttomlrK   r)   r)   r*   rP   w   rM   zTestdir.makepyprojecttomlc                 O   ó   t | jj|i |¤ŽƒS )z See :meth:`Pytester.makepyfile`.)r   r'   Ú
makepyfile©r(   rG   rH   r)   r)   r*   rR   {   ó   zTestdir.makepyfilec                 O   rQ   )z!See :meth:`Pytester.maketxtfile`.)r   r'   ÚmaketxtfilerS   r)   r)   r*   rU      rT   zTestdir.maketxtfilec                 C   r;   )z#See :meth:`Pytester.syspathinsert`.)r'   Úsyspathinsert©r(   r-   r)   r)   r*   rV   ƒ   r2   zTestdir.syspathinsertc                 C   rI   )zSee :meth:`Pytester.mkdir`.)r   r'   Úmkdir©r(   Únamer)   r)   r*   rX   ‡   rM   zTestdir.mkdirc                 C   rI   )zSee :meth:`Pytester.mkpydir`.)r   r'   ÚmkpydirrY   r)   r)   r*   r[   ‹   rM   zTestdir.mkpydirc                 C   rI   )z"See :meth:`Pytester.copy_example`.)r   r'   Úcopy_examplerY   r)   r)   r*   r\   �   rM   zTestdir.copy_exampleÚconfigc                 C   ó   | j  ||¡S )zSee :meth:`Pytester.getnode`.)r'   Úgetnode)r(   r]   Úargr)   r)   r*   r_   “   ó   zTestdir.getnodec                 C   r;   )z!See :meth:`Pytester.getpathnode`.)r'   ÚgetpathnoderW   r)   r)   r*   rb   —   r2   zTestdir.getpathnodeÚcolitemsc                 C   r;   )zSee :meth:`Pytester.genitems`.)r'   Úgenitems)r(   rc   r)   r)   r*   rd   ›   r2   zTestdir.genitemsc                 C   r;   )zSee :meth:`Pytester.runitem`.)r'   ÚrunitemrK   r)   r)   r*   re   Ÿ   r2   zTestdir.runitemc                 G   s   | j j|g|¢R Ž S )z&See :meth:`Pytester.inline_runsource`.)r'   Úinline_runsource)r(   rL   Úcmdlineargsr)   r)   r*   rf   £   ó   zTestdir.inline_runsourcec                 G   ó   | j j|Ž S )z%See :meth:`Pytester.inline_genitems`.)r'   Úinline_genitems©r(   rG   r)   r)   r*   rj   §   r2   zTestdir.inline_genitemsr)   ©r8   Úno_reraise_ctrlcrm   c                G   ó   | j j|||dœŽS )z See :meth:`Pytester.inline_run`.rl   )r'   Ú
inline_run)r(   r8   rm   rG   r)   r)   r*   ro   «   s   ÿzTestdir.inline_runc                 O   ó   | j j|i |¤ŽS )z)See :meth:`Pytester.runpytest_inprocess`.)r'   Úrunpytest_inprocessrS   r)   r)   r*   rq   ±   ó   zTestdir.runpytest_inprocessc                 O   rp   )zSee :meth:`Pytester.runpytest`.)r'   Ú	runpytestrS   r)   r)   r*   rs   µ   rr   zTestdir.runpytestc                 G   ri   )z!See :meth:`Pytester.parseconfig`.)r'   Úparseconfigrk   r)   r)   r*   rt   ¹   r2   zTestdir.parseconfigc                 G   ri   )z$See :meth:`Pytester.parseconfigure`.)r'   Úparseconfigurerk   r)   r)   r*   ru   ½   r2   zTestdir.parseconfigureÚ	test_funcc                 C   r^   )zSee :meth:`Pytester.getitem`.)r'   Úgetitem)r(   rL   Úfuncnamer)   r)   r*   rw   Á   ra   zTestdir.getitemc                 C   r;   )zSee :meth:`Pytester.getitems`.)r'   ÚgetitemsrK   r)   r)   r*   ry   Å   r2   zTestdir.getitemsc                 C   s   | j j|||d�S )z"See :meth:`Pytester.getmodulecol`.)Ú
configargsÚwithinit)r'   Úgetmodulecol)r(   rL   rz   r{   r)   r)   r*   r|   É   s   ÿzTestdir.getmodulecolÚmodcolrZ   c                 C   r^   )z%See :meth:`Pytester.collect_by_name`.)r'   Úcollect_by_name)r(   r}   rZ   r)   r)   r*   r~   Ï   s   zTestdir.collect_by_namec                 K   s   | j j||||fi |¤ŽS )zSee :meth:`Pytester.popen`.)r'   Úpopen)r(   ÚcmdargsÚstdoutÚstderrÚstdinÚkwr)   r)   r*   r   Õ   s   	zTestdir.popen©Útimeoutrƒ   c                G   rn   )zSee :meth:`Pytester.run`.r…   )r'   Úrun)r(   r†   rƒ   r€   r)   r)   r*   r‡   à   rh   zTestdir.runc                 C   r;   )zSee :meth:`Pytester.runpython`.)r'   Ú	runpython)r(   Úscriptr)   r)   r*   rˆ   ä   r2   zTestdir.runpythonc                 C   r;   )z!See :meth:`Pytester.runpython_c`.)r'   Úrunpython_c)r(   Úcommandr)   r)   r*   rŠ   è   r2   zTestdir.runpython_c)r†   c                G   s   | j j|d|iŽS )z*See :meth:`Pytester.runpytest_subprocess`.r†   )r'   Úrunpytest_subprocess)r(   r†   rG   r)   r)   r*   rŒ   ì   rr   zTestdir.runpytest_subprocessç      $@ÚstringÚexpect_timeoutzpexpect.spawnc                 C   ó   | j j||d�S )z"See :meth:`Pytester.spawn_pytest`.©r�   )r'   Úspawn_pytest)r(   rŽ   r�   r)   r)   r*   r’   ð   s   zTestdir.spawn_pytestÚcmdc                 C   r�   )zSee :meth:`Pytester.spawn`.r‘   )r'   Úspawn)r(   r“   r�   r)   r)   r*   r”   ö   rM   zTestdir.spawnc                 C   s   d| j ›d�S )Nz	<Testdir ú>)r/   r.   r)   r)   r*   Ú__repr__ú   ó   zTestdir.__repr__c                 C   ó
   t | jƒS r&   )Ústrr/   r.   r)   r)   r*   Ú__str__ý   s   
zTestdir.__str__)r$   Nr&   )rv   )r)   F)r�   )GÚ__name__Ú
__module__Ú__qualname__Ú__doc__Ú__test__r   r   Ú__annotations__r    Úboolr+   Úpropertyr
   r/   r1   r5   r8   Úsetterr   r:   r   r<   r?   rB   rE   rJ   rN   r™   r   rO   rP   rR   rU   rV   rX   r[   r\   r   r   r   r   r   r_   rb   r   rd   re   rf   rj   ro   r   rq   rs   rt   ru   rw   ry   r|   r~   Ú
subprocessÚPIPEr   r‡   rˆ   rŠ   rŒ   Úfloatr’   r”   r–   rš   r)   r)   r)   r*   r   (   s�   
 




"

ÿÿ
þ	
ûÿÿÿ
þr   c                   @   s&   e Zd Zeededefdd„ƒƒZdS )ÚLegacyTestdirPluginr#   r$   c                 C   s   t | dd�S )zú
        Identical to :fixture:`pytester`, and provides an instance whose methods return
        legacy ``LEGACY_PATH`` objects instead when applicable.

        New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
        Tr!   )r   )r#   r)   r)   r*   Útestdir  s   	zLegacyTestdirPlugin.testdirN)r›   rœ   r�   Ústaticmethodr   r   r   r¨   r)   r)   r)   r*   r§     s    r§   c                   @   s\   e Zd ZU dZeed< ddœdededdfd	d
„Zddedede	fdd„Z
de	fdd„ZdS )ÚTempdirFactorya  Backward compatibility wrapper that implements :class:`py.path.local`
    for :class:`TempPathFactory`.

    .. note::
        These days, it is preferred to use ``tmp_path_factory``.

        :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.

    Ú_tmppath_factoryFr!   Útmppath_factoryr"   r$   Nc                C   r%   r&   )r   r«   )r(   r¬   r"   r)   r)   r*   r+     s   
zTempdirFactory.__init__TÚbasenameÚnumberedc                 C   s   t | j ||¡ ¡ ƒS )zTSame as :meth:`TempPathFactory.mktemp`, but returns a :class:`py.path.local` object.)r   r«   ÚmktempÚresolve)r(   r­   r®   r)   r)   r*   r¯   #  rT   zTempdirFactory.mktempc                 C   s   t | j ¡  ¡ ƒS )zYSame as :meth:`TempPathFactory.getbasetemp`, but returns a :class:`py.path.local` object.)r   r«   Úgetbasetempr°   r.   r)   r)   r*   r±   '  rr   zTempdirFactory.getbasetemp)T)r›   rœ   r�   rž   r   r    r¡   r+   r™   r
   r¯   r±   r)   r)   r)   r*   rª     s   
 
ÿÿÿ
þrª   c                   @   sF   e Zd Zeedd�dedefdd„ƒƒZeedede	fdd	„ƒƒZ
d
S )ÚLegacyTmpdirPluginÚsession)Úscoper5   r$   c                 C   r3   )zFReturn a :class:`pytest.TempdirFactory` instance for the test session.)r]   Ú_tmpdirhandler)r5   r)   r)   r*   Útmpdir_factory-  s   z!LegacyTmpdirPlugin.tmpdir_factoryÚtmp_pathc                 C   s   t | ƒS )aè  Return a temporary directory path object which is unique to each test
        function invocation, created as a sub directory of the base temporary
        directory.

        By default, a new base temporary directory is created each test session,
        and old bases are removed after 3 sessions, to aid in debugging. If
        ``--basetemp`` is used then it is cleared each session. See :ref:`base
        temporary directory`.

        The returned object is a `legacy_path`_ object.

        .. note::
            These days, it is preferred to use ``tmp_path``.

            :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.

        .. _legacy_path: https://py.readthedocs.io/en/latest/path.html
        r   )r·   r)   r)   r*   r/   4  s   zLegacyTmpdirPlugin.tmpdirN)r›   rœ   r�   r©   r   r   rª   r¶   r   r
   r/   r)   r)   r)   r*   r²   ,  s    r²   r(   rZ   r$   c                 C   s   t |  |¡ƒS )z{Return a directory path object with the given name.

    Same as :func:`mkdir`, but returns a legacy py path instance.
    )r   rX   rY   r)   r)   r*   ÚCache_makedirL  s   r¸   c                 C   r˜   )zO(deprecated) The file system path of the test module which collected this test.©r   r-   r.   r)   r)   r*   ÚFixtureRequest_fspathT  r@   rº   c                 C   r˜   )zŒThe directory from which pytest was invoked.

    Prefer to use ``startpath`` which is a :class:`pathlib.Path`.

    :type: LEGACY_PATH
    ©r   Ú	startpathr.   r)   r)   r*   ÚTerminalReporter_startdirY  ó   
r½   c                 C   s   t t| jjƒƒS )z¸The directory from which pytest was invoked.

    Prefer to use :attr:`invocation_params.dir <InvocationParams.dir>`,
    which is a :class:`pathlib.Path`.

    :type: LEGACY_PATH
    )r   r™   Úinvocation_paramsÚdirr.   r)   r)   r*   ÚConfig_invocation_dirc  s   rÁ   c                 C   s   t t| jƒƒS )z�The path to the :ref:`rootdir <rootdir>`.

    Prefer to use :attr:`rootpath`, which is a :class:`pathlib.Path`.

    :type: LEGACY_PATH
    )r   r™   Úrootpathr.   r)   r)   r*   ÚConfig_rootdirn  s   rÃ   c                 C   s   | j r
tt| j ƒƒS dS )z�The path to the :ref:`configfile <configfiles>`.

    Prefer to use :attr:`inipath`, which is a :class:`pathlib.Path`.

    :type: Optional[LEGACY_PATH]
    N)Úinipathr   r™   r.   r)   r)   r*   ÚConfig_inifilex  s   rÅ   c                 C   r˜   )z‡The path from which pytest was invoked.

    Prefer to use ``startpath`` which is a :class:`pathlib.Path`.

    :type: LEGACY_PATH
    r»   r.   r)   r)   r*   ÚSession_stardir‚  r¾   rÆ   ÚtypeÚvaluec                    sX   |dkr$| j d usJ ‚| j j‰ t|tƒrt |¡n|}‡ fdd„|D ƒS td|› �|ƒ‚)NÚpathlistc                    s   g | ]
}t tˆ | ƒƒ‘qS r)   )r   r™   )Ú.0Úx©Údpr)   r*   Ú
<listcomp>”  s    z/Config__getini_unknown_type.<locals>.<listcomp>zunknown configuration type: )rÄ   ÚparentÚ
isinstancer™   ÚshlexÚsplitÚ
ValueError)r(   rZ   rÇ   rÈ   Úinput_valuesr)   rÌ   r*   ÚConfig__getini_unknown_typeŒ  s   rÕ   c                 C   r˜   )z4(deprecated) returns a legacy_path copy of self.pathr¹   r.   r)   r)   r*   ÚNode_fspath™  r@   rÖ   c                 C   s   t |ƒ| _d S r&   )r   r-   )r(   rÈ   r)   r)   r*   ÚNode_fspath_setž  r—   r×   T)ÚtryfirstÚearly_configc                 C   sÒ   t ƒ }|  |j¡ |jtdtdd� |jtdttƒdd� |jt	dtt
ƒdd� |jtdttƒdd� |jtdttƒdd� |jtdttƒdd� |jtdttƒdd� | td	t¡ |jtdtttƒdd� d
S )zLMonkeypatch legacy path attributes in several classes, as early as possible.ÚmakedirF©ÚraisingÚfspathÚstartdirÚinvocation_dirÚrootdirÚinifileÚ_getini_unknown_typeN)r   Úadd_cleanupÚundoÚsetattrr   r¸   r   r¢   rº   r   r½   r   rÁ   rÃ   rÅ   r   rÆ   rÕ   r   rÖ   r×   )rÙ   Úmpr)   r)   r*   Úpytest_load_initial_conftests¢  s   ÿrç   r]   c                 C   sp   | j  d¡r6tƒ }|  |j¡ z| j}W n	 ty   Y nw t|dd�}|j| d|dd� | j  	t
d¡ dS dS )	zKInstalls the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed.r/   Tr!   rµ   FrÛ   zlegacypath-tmpdirN)r=   Ú
has_pluginr   rã   rä   Ú_tmp_path_factoryÚAttributeErrorrª   rå   Úregisterr²   )r]   ræ   Útmp_path_factoryrµ   r)   r)   r*   Úpytest_configureÂ  s   
þïrí   ÚpluginÚmanagerc                 C   s4   | |  d¡u }|r| t¡s| td¡ d S d S d S )Nr#   zlegacypath-pytester)Ú
get_pluginÚis_registeredr§   rë   )rî   rï   Úis_pytesterr)   r)   r*   Úpytest_plugin_registeredÙ  s   ÿró   )Crž   ÚdataclassesrÑ   r¤   Úpathlibr   Útypingr   r   r   r   Ú	iniconfigr   Ú_pytest.cacheproviderr   Ú_pytest.compatr	   r
   r   Ú_pytest.configr   r   r   Ú_pytest.deprecatedr   Ú_pytest.fixturesr   r   Ú_pytest.mainr   Ú_pytest.monkeypatchr   Ú_pytest.nodesr   r   r   Ú_pytest.pytesterr   r   r   Ú_pytest.terminalr   Ú_pytest.tmpdirr   Útyping_extensionsr   Úpexpectr   r§   Ú	dataclassrª   r²   r™   r¸   rº   r½   rÁ   rÃ   rÅ   rÆ   rÕ   rÖ   r×   rç   rí   Úobjectró   r)   r)   r)   r*   Ú<module>   s~     Y 



ÿÿ
ÿ