U
    `»{jÌ@  ã                   @  sŠ  d Z ddlmZ ddlZddlmZ ddlZddlZddlm	Z	 ddlm
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddl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�rVddl,Z,e
G dd„ dƒƒZ-G dd„ dƒZ.e
ej/G d d!„ d!ƒƒƒZ0G d"d#„ d#ƒZ1d$d%d&d'œd(d)„Z2d*d&d+œd,d-„Z3d.d&d+œd/d0„Z4d1d&d+œd2d3„Z5d1d&d+œd4d5„Z6d1d6d+œd7d8„Z7d9d&d+œd:d;„Z8d%d%d<d=œd>d?„Z9d@d&d+œdAdB„Z:d@d&dCdDœdEdF„Z;edGdH�d1dCdIœdJdK„ƒZ<ed1dCdLœdMdN„ƒZ=edOdPdCdQœdRdS„ƒZ>dS )Tz?Add backward compatibility support for the legacy py path type.é    )ÚannotationsN)ÚPath)ÚFinal)Úfinal)ÚTYPE_CHECKING)ÚSectionWrapper)ÚCache)ÚLEGACY_PATH©Úlegacy_path)ÚConfig)Úhookimpl)ÚPytestPluginManager)Úcheck_ispytest)Úfixture)ÚFixtureRequest)ÚSession)ÚMonkeyPatch)Ú	Collector)ÚItem)ÚNode)ÚHookRecorder)ÚPytester)Ú	RunResult)ÚTerminalReporter)ÚTempPathFactoryc                   @  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dd	d
œdd„Z	e
ddœdd„ƒZe
ddœdd„ƒZe
dd„ ƒZe
dd„ ƒZejdd„ ƒZe
ddœdd„ƒZddœdd„Zd	dœdd„Zd	dœd d!„Zddœd"d#„Zddœd$d%„Zddœd&d'„Zd(d)d*œd+d,„Zddœd-d.„Zddœd/d0„Zddœd1d2„Zd€d	dœd4d5„Zddœd6d7„Zddœd8d9„Zd�ddœd:d;„Zd<d=d>œd?d@„ZdAdB„ Z dCdDdEœdFdG„Z!dHdI„ Z"dJdK„ Z#dLdM„ Z$dNddOœddPœdQdR„Z%dSdœdTdU„Z&dSdœdVdW„Z'd<dœdXdY„Z(d<dœdZd[„Z)d‚d]d^„Z*d_d`„ Z+dƒdadb„Z,dcd(d=ddœdedf„Z-e.j/e.j/efdgdh„Z0d3ediœdSdœdjdk„Z1dSdœdldm„Z2dndo„ Z3d3dpœdSdœdqdr„Z4d„d(dtdudvœdwdx„Z5d…d(dtdudyœdzd{„Z6d(dœd|d}„Z7d(dœd~d„Z8d3S )†Ú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©Ú	_ispytestr   ÚboolÚNone)Úpytesterr    Úreturnc                C  s   t |ƒ || _d S ©N)r   Ú	_pytester)Úselfr#   r    © r(   úQ/var/www/html/bwave/python/venv/lib/python3.8/site-packages/_pytest/legacypath.pyÚ__init__7   s    zTestdir.__init__r	   ©r$   c                 C  s   t | jjƒS )z-Temporary directory where tests are executed.)r   r&   Úpath©r'   r(   r(   r)   Útmpdir;   s    zTestdir.tmpdirc                 C  s   t | jjƒS r%   )r   r&   Z_test_tmprootr-   r(   r(   r)   Útest_tmproot@   s    zTestdir.test_tmprootc                 C  s   | j jS r%   )r&   Ú_requestr-   r(   r(   r)   ÚrequestD   s    zTestdir.requestc                 C  s   | j jS r%   ©r&   Úpluginsr-   r(   r(   r)   r3   H   s    zTestdir.pluginsc                 C  s   || j _d S r%   r2   )r'   r3   r(   r(   r)   r3   L   s    r   c                 C  s   | j jS r%   )r&   Z_monkeypatchr-   r(   r(   r)   ÚmonkeypatchP   s    zTestdir.monkeypatchr   c                 C  s   | j  |¡S )z(See :meth:`Pytester.make_hook_recorder`.)r&   Úmake_hook_recorder)r'   Úpluginmanagerr(   r(   r)   r5   T   s    zTestdir.make_hook_recorderc                 C  s
   | j  ¡ S )zSee :meth:`Pytester.chdir`.)r&   Úchdirr-   r(   r(   r)   r7   X   s    zTestdir.chdirc                 C  s
   | j  ¡ S r%   )r&   Z	_finalizer-   r(   r(   r)   Úfinalize\   s    zTestdir.finalizec                 O  s.   |r|  d¡sd| }t| jj|f|ž|ŽƒS )zSee :meth:`Pytester.makefile`.Ú.)Ú
startswithr   r&   Úmakefile)r'   ÚextÚargsÚkwargsr(   r(   r)   r;   _   s    zTestdir.makefilec                 C  s   t | j |¡ƒS )z"See :meth:`Pytester.makeconftest`.)r   r&   Úmakeconftest©r'   Úsourcer(   r(   r)   r?   k   s    zTestdir.makeconftestc                 C  s   t | j |¡ƒS )zSee :meth:`Pytester.makeini`.)r   r&   Úmakeinir@   r(   r(   r)   rB   o   s    zTestdir.makeiniÚstrr   )rA   r$   c                 C  s   | j  |¡S )zSee :meth:`Pytester.getinicfg`.)r&   Ú	getinicfgr@   r(   r(   r)   rD   s   s    zTestdir.getinicfgc                 C  s   t | j |¡ƒS )z'See :meth:`Pytester.makepyprojecttoml`.)r   r&   Úmakepyprojecttomlr@   r(   r(   r)   rE   w   s    zTestdir.makepyprojecttomlc                 O  s   t | jj||ŽƒS )z See :meth:`Pytester.makepyfile`.)r   r&   Ú
makepyfile©r'   r=   r>   r(   r(   r)   rF   {   s    zTestdir.makepyfilec                 O  s   t | jj||ŽƒS )z!See :meth:`Pytester.maketxtfile`.)r   r&   ÚmaketxtfilerG   r(   r(   r)   rH      s    zTestdir.maketxtfileNc                 C  s   | j  |¡S )z#See :meth:`Pytester.syspathinsert`.)r&   Úsyspathinsert©r'   r,   r(   r(   r)   rI   ƒ   s    zTestdir.syspathinsertc                 C  s   t | j |¡ƒS )zSee :meth:`Pytester.mkdir`.)r   r&   Úmkdir©r'   Únamer(   r(   r)   rK   ‡   s    zTestdir.mkdirc                 C  s   t | j |¡ƒS )zSee :meth:`Pytester.mkpydir`.)r   r&   ÚmkpydirrL   r(   r(   r)   rN   ‹   s    zTestdir.mkpydirc                 C  s   t | j |¡ƒS )z"See :meth:`Pytester.copy_example`.)r   r&   Úcopy_examplerL   r(   r(   r)   rO   �   s    zTestdir.copy_exampler   zItem | Collector | None©Úconfigr$   c                 C  s   | j  ||¡S )zSee :meth:`Pytester.getnode`.)r&   Úgetnode)r'   rQ   Úargr(   r(   r)   rR   “   s    zTestdir.getnodec                 C  s   | j  |¡S )z!See :meth:`Pytester.getpathnode`.)r&   ÚgetpathnoderJ   r(   r(   r)   rT   —   s    zTestdir.getpathnodezlist[Item | Collector]z
list[Item])Úcolitemsr$   c                 C  s   | j  |¡S )zSee :meth:`Pytester.genitems`.)r&   Úgenitems)r'   rU   r(   r(   r)   rV   ›   s    zTestdir.genitemsc                 C  s   | j  |¡S )zSee :meth:`Pytester.runitem`.)r&   Úrunitemr@   r(   r(   r)   rW   Ÿ   s    zTestdir.runitemc                 G  s   | j j|f|žŽ S )z&See :meth:`Pytester.inline_runsource`.)r&   Úinline_runsource)r'   rA   Zcmdlineargsr(   r(   r)   rX   £   s    zTestdir.inline_runsourcec                 G  s   | j j|Ž S )z%See :meth:`Pytester.inline_genitems`.)r&   Úinline_genitems©r'   r=   r(   r(   r)   rY   §   s    zTestdir.inline_genitemsr(   ©r3   Úno_reraise_ctrlc)r\   c                G  s   | j j|||dœŽS )z See :meth:`Pytester.inline_run`.r[   )r&   Ú
inline_run)r'   r3   r\   r=   r(   r(   r)   r]   «   s
      ÿzTestdir.inline_runr   c                 O  s   | j j||ŽS )z)See :meth:`Pytester.runpytest_inprocess`.)r&   Úrunpytest_inprocessrG   r(   r(   r)   r^   ±   s    zTestdir.runpytest_inprocessc                 O  s   | j j||ŽS )zSee :meth:`Pytester.runpytest`.)r&   Ú	runpytestrG   r(   r(   r)   r_   µ   s    zTestdir.runpytestc                 G  s   | j j|Ž S )z!See :meth:`Pytester.parseconfig`.)r&   ÚparseconfigrZ   r(   r(   r)   r`   ¹   s    zTestdir.parseconfigc                 G  s   | j j|Ž S )z$See :meth:`Pytester.parseconfigure`.)r&   ÚparseconfigurerZ   r(   r(   r)   ra   ½   s    zTestdir.parseconfigureÚ	test_funcc                 C  s   | j  ||¡S )zSee :meth:`Pytester.getitem`.)r&   Úgetitem)r'   rA   Úfuncnamer(   r(   r)   rc   Á   s    zTestdir.getitemc                 C  s   | j  |¡S )zSee :meth:`Pytester.getitems`.)r&   Úgetitemsr@   r(   r(   r)   re   Å   s    zTestdir.getitemsc                 C  s   | j j|||d�S )z"See :meth:`Pytester.getmodulecol`.)Ú
configargsÚwithinit)r&   Úgetmodulecol)r'   rA   rf   rg   r(   r(   r)   rh   É   s
      ÿzTestdir.getmodulecolr   )ÚmodcolrM   r$   c                 C  s   | j  ||¡S )z%See :meth:`Pytester.collect_by_name`.)r&   Úcollect_by_name)r'   ri   rM   r(   r(   r)   rj   Ï   s    zTestdir.collect_by_namec                 K  s   | j j||||f|ŽS )zSee :meth:`Pytester.popen`.)r&   Úpopen)r'   ÚcmdargsÚstdoutÚstderrÚstdinÚkwr(   r(   r)   rk   Ó   s    	zTestdir.popen©Útimeoutro   c                G  s   | j j|||dœŽS )zSee :meth:`Pytester.run`.rq   )r&   Úrun)r'   rr   ro   rl   r(   r(   r)   rs   Þ   s    zTestdir.runc                 C  s   | j  |¡S )zSee :meth:`Pytester.runpython`.)r&   Ú	runpython)r'   Úscriptr(   r(   r)   rt   â   s    zTestdir.runpythonc                 C  s   | j  |¡S )z!See :meth:`Pytester.runpython_c`.)r&   Úrunpython_c)r'   Úcommandr(   r(   r)   rv   æ   s    zTestdir.runpython_c)rr   c                G  s   | j j|d|iŽS )z*See :meth:`Pytester.runpytest_subprocess`.rr   )r&   Úrunpytest_subprocess)r'   rr   r=   r(   r(   r)   rx   ê   s    zTestdir.runpytest_subprocessç      $@Úfloatzpexpect.spawn)ÚstringÚexpect_timeoutr$   c                 C  s   | 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)Úcmdr|   r$   c                 C  s   | j j||d�S )zSee :meth:`Pytester.spawn`.r}   )r&   Úspawn)r'   r   r|   r(   r(   r)   r€   ò   s    zTestdir.spawnc                 C  s   d| j ›d�S )Nz	<Testdir ú>)r.   r-   r(   r(   r)   Ú__repr__ö   s    zTestdir.__repr__c                 C  s
   t | jƒS r%   )rC   r.   r-   r(   r(   r)   Ú__str__ù   s    zTestdir.__str__)N)N)rb   )r(   F)ry   )ry   )9Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z__test__r   r   Ú__annotations__r   r*   Úpropertyr.   r/   r1   r3   Úsetterr4   r5   r7   r8   r;   r?   rB   rD   rE   rF   rH   rI   rK   rN   rO   rR   rT   rV   rW   rX   rY   r]   r^   r_   r`   ra   rc   re   rh   rj   Ú
subprocessÚPIPErk   rs   rt   rv   rx   r~   r€   r‚   rƒ   r(   r(   r(   r)   r   )   st   





û
r   c                   @  s$   e Zd Zeedddœdd„ƒƒZdS )ÚLegacyTestdirPluginr   r   )r#   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�   ý   s   r�   c                   @  sT   e Zd ZU dZded< ddœddddœd	d
„Zdddddœdd„Zddœdd„ZdS )ÚTempdirFactorya  Backward compatibility wrapper that implements ``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>`.

    r   Ú_tmppath_factoryFr   r!   r"   )Útmppath_factoryr    r$   c                C  s   t |ƒ || _d S r%   )r   r‘   )r'   r’   r    r(   r(   r)   r*     s    zTempdirFactory.__init__TrC   r	   )ÚbasenameÚnumberedr$   c                 C  s   t | j ||¡ ¡ ƒS )zOSame as :meth:`TempPathFactory.mktemp`, but returns a ``py.path.local`` object.)r   r‘   ÚmktempÚresolve)r'   r“   r”   r(   r(   r)   r•     s    zTempdirFactory.mktempr+   c                 C  s   t | j ¡  ¡ ƒS )zTSame as :meth:`TempPathFactory.getbasetemp`, but returns a ``py.path.local`` object.)r   r‘   Úgetbasetempr–   r-   r(   r(   r)   r—   #  s    zTempdirFactory.getbasetempN)T)r„   r…   r†   r‡   rˆ   r*   r•   r—   r(   r(   r(   r)   r�   
  s   

ÿr�   c                   @  sB   e Zd Zeedd�dddœdd„ƒƒZeedd	d
œdd„ƒƒZdS )ÚLegacyTmpdirPluginÚsession)Úscoper   r�   )r1   r$   c                 C  s   | j jS )zFReturn a :class:`pytest.TempdirFactory` instance for the test session.)rQ   Ú_tmpdirhandler)r1   r(   r(   r)   Útmpdir_factory)  s    z!LegacyTmpdirPlugin.tmpdir_factoryr   r	   )Útmp_pathr$   c                 C  s   t | ƒS )a=  Return a temporary directory (as `legacy_path`_ object)
        which is unique to each test function invocation.
        The temporary directory is created as a subdirectory
        of the base temporary directory, with configurable retention,
        as discussed in :ref:`temporary directory location and retention`.

        .. 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.   0  s    zLegacyTmpdirPlugin.tmpdirN)r„   r…   r†   r�   r   rœ   r.   r(   r(   r(   r)   r˜   (  s   r˜   r   rC   r	   )r'   rM   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   rK   rL   r(   r(   r)   ÚCache_makedirC  s    rž   r   )r'   r$   c                 C  s
   t | jƒS )zO(deprecated) The file system path of the test module which collected this test.©r   r,   r-   r(   r(   r)   ÚFixtureRequest_fspathK  s    r    r   c                 C  s
   t | jƒS )zŒThe directory from which pytest was invoked.

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

    :type: LEGACY_PATH
    ©r   Z	startpathr-   r(   r(   r)   ÚTerminalReporter_startdirP  s    r¢   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   rC   Zinvocation_paramsÚdirr-   r(   r(   r)   ÚConfig_invocation_dirZ  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   rC   Zrootpathr-   r(   r(   r)   ÚConfig_rootdire  s    r¥   zLEGACY_PATH | Nonec                 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   rC   r-   r(   r(   r)   ÚConfig_inifileo  s    r§   r   c                 C  s
   t | jƒS )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_startdiry  s    r¨   zstr | list[str])rM   ÚtypeÚvaluec                   s\   |dkrH| j d k	st‚| j j‰ t|tƒr2t |¡n|}‡ fdd„|D ƒS td|› �|ƒ‚d S )NZpathlistc                   s   g | ]}t tˆ | ƒƒ‘qS r(   )r   rC   )Ú.0Úx©Zdpr(   r)   Ú
<listcomp>‰  s     z/Config__getini_unknown_type.<locals>.<listcomp>zunknown configuration type: )r¦   ÚAssertionErrorÚparentÚ
isinstancerC   ÚshlexÚsplitÚ
ValueError)r'   rM   r©   rª   Zinput_valuesr(   r­   r)   ÚConfig__getini_unknown_typeƒ  s    rµ   r   c                 C  s
   t | jƒS )z4(deprecated) returns a legacy_path copy of self.pathrŸ   r-   r(   r(   r)   ÚNode_fspathŽ  s    r¶   r"   )r'   rª   r$   c                 C  s   t |ƒ| _d S r%   )r   r,   )r'   rª   r(   r(   r)   ÚNode_fspath_set“  s    r·   T)Ztryfirst)Úearly_configr$   c                 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©ZraisingÚfspathZstartdirZinvocation_dirÚrootdirZinifileZ_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Á   rP   c                 C  sn   | j  d¡rjtƒ }|  |j¡ z
| j}W n tk
r<   Y n X t|dd�}|j| d|dd� | j  	t
d¡ dS )	zKInstalls the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed.r.   Tr   r›   Frº   zlegacypath-tmpdirN)r6   Z
has_pluginr   r½   r¾   Z_tmp_path_factoryÚAttributeErrorr�   r¿   Úregisterr˜   )rQ   rÀ   Ztmp_path_factoryr›   r(   r(   r)   Úpytest_configure·  s    
rÄ   Úobjectr   )ÚpluginÚmanagerr$   c                 C  s,   | |  d¡k}|r(| t¡s(| td¡ d S )Nr#   zlegacypath-pytester)Z
get_pluginZis_registeredr�   rÃ   )rÆ   rÇ   Zis_pytesterr(   r(   r)   Úpytest_plugin_registeredÎ  s    rÈ   )?r‡   Ú
__future__r   ÚdataclassesÚpathlibr   r²   r‹   Útypingr   r   r   Z	iniconfigr   Z_pytest.cacheproviderr   Z_pytest.compatr	   r   Z_pytest.configr   r   r   Z_pytest.deprecatedr   Z_pytest.fixturesr   r   Z_pytest.mainr   Z_pytest.monkeypatchr   Z_pytest.nodesr   r   r   Z_pytest.pytesterr   r   r   Z_pytest.terminalr   Z_pytest.tmpdirr   Zpexpectr   r�   Ú	dataclassr�   r˜   rž   r    r¢   r¤   r¥   r§   r¨   rµ   r¶   r·   rÁ   rÄ   rÈ   r(   r(   r(   r)   Ú<module>   sl    T



