a
    !f!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	rnd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%Z3ee4ed&d'd(Z5eed)d*d+Z6e)ed)d,d-Z7eed)d.d/Z8eed)d0d1Z9eee d)d2d3Z:eed)d4d5Z;e4e4e
e4ee4 f d6d7d8Z<e#ed)d9d:Z=e#edd;d<d=Z>ed>d?edd@dAdBZ?eeddCdDdEZ@eeAeddFdGdHZBdS )Iz?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ee	ddd	d
Z
eedddZeedddZedd Zedd Zejdd ZeedddZedddZddddZddddZedddZeddd Zedd!d"Zeed#d$d%Zedd&d'Zedd(d)Zedd*d+Z dqddd,d-Z!edd.d/Z"edd0d1Z#dredd2d3Z$e%e&e'e(e)f  d4d5d6Z*d7d8 Z+e,e'e(e)f  e,e( d9d:d;Z-d<d= Z.d>d? Z/d@dA Z0dBddCe	dDdEdFZ1e2ddGdHZ3e2ddIdJZ4e%ddKdLZ5e%ddMdNZ6dsdPdQZ7dRdS Z8dtdTdUZ9e)ee&e'e(e)f  dVdWdXZ:e;j<e;j<efdYdZZ=ded[e2dd\d]Z>e2dd^d_Z?d`da Z@ddbe2ddcddZAdueeBdfdgdhdiZCdveeBdfdjdkdlZDeddmdnZEeddodpZFdS )w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	_ispytestN)pytesterr"   returnc                C   s   t | || _d S N)r   	_pytester)selfr#   r"    r(   S/var/www/html/python-backend/venv/lib/python3.9/site-packages/_pytest/legacypath.py__init__6   s    zTestdir.__init__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)   requestC   s    zTestdir.requestc                 C   s   | j jS r%   r&   pluginsr-   r(   r(   r)   r3   G   s    zTestdir.pluginsc                 C   s   || j _d S r%   r2   )r'   r3   r(   r(   r)   r3   K   s    c                 C   s   | j jS r%   )r&   Z_monkeypatchr-   r(   r(   r)   monkeypatchO   s    zTestdir.monkeypatchc                 C   s   | j |S )z(See :meth:`Pytester.make_hook_recorder`.)r&   make_hook_recorder)r'   pluginmanagerr(   r(   r)   r5   S   s    zTestdir.make_hook_recorderc                 C   s
   | j  S )zSee :meth:`Pytester.chdir`.)r&   chdirr-   r(   r(   r)   r7   W   s    zTestdir.chdirc                 C   s
   | j  S )zSee :meth:`Pytester._finalize`.)r&   	_finalizer-   r(   r(   r)   finalize[   s    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)   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&   makeinirA   r(   r(   r)   rC   o   s    zTestdir.makeini)rB   r$   c                 C   s   | j |S )zSee :meth:`Pytester.getinicfg`.)r&   	getinicfgrA   r(   r(   r)   rD   s   s    zTestdir.getinicfgc                 C   s   t | j|S )z'See :meth:`Pytester.makepyprojecttoml`.)r   r&   makepyprojecttomlrA   r(   r(   r)   rE   w   s    zTestdir.makepyprojecttomlc                 O   s   t | jj|i |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|i |S )z!See :meth:`Pytester.maketxtfile`.)r   r&   maketxtfilerG   r(   r(   r)   rH      s    zTestdir.maketxtfilec                 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_example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.getpathnode)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&   runitemrA   r(   r(   r)   rW      s    zTestdir.runitemc                 G   s   | j j|g|R  S )z&See :meth:`Pytester.inline_runsource`.)r&   inline_runsource)r'   rB   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_runc                 O   s   | j j|i |S )z)See :meth:`Pytester.runpytest_inprocess`.)r&   runpytest_inprocessrG   r(   r(   r)   r^      s    zTestdir.runpytest_inprocessc                 O   s   | j j|i |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'   rB   funcnamer(   r(   r)   rc      s    zTestdir.getitemc                 C   s   | j |S )zSee :meth:`Pytester.getitems`.)r&   getitemsrA   r(   r(   r)   re      s    zTestdir.getitemsc                 C   s   | j j|||dS )z"See :meth:`Pytester.getmodulecol`.)
configargswithinit)r&   getmodulecol)r'   rB   rf   rg   r(   r(   r)   rh      s    zTestdir.getmodulecol)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i |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      $@zpexpect.spawn)stringexpect_timeoutr$   c                 C   s   | j j||dS )z"See :meth:`Pytester.spawn_pytest`.r{   )r&   spawn_pytest)r'   rz   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%   )strr.   r-   r(   r(   r)   __str__   s    zTestdir.__str__)N)N)rb   )r(   F)ry   )ry   )G__name__
__module____qualname____doc__Z__test__r   r   __annotations__r    boolr*   propertyr
   r.   r/   r1   r3   setterr   r4   r   r5   r7   r9   r<   r@   rC   r   r   rD   rE   rF   rH   rI   rK   rN   rO   r   r   r   r   r   rR   rT   r   rV   rW   rX   rY   r]   r   r^   r_   r`   ra   rc   re   rh   rj   
subprocessPIPErk   rs   rt   rv   rx   floatr}   r   r   r   r(   r(   r(   r)   r   (   s   



 

	
 r   c                   @   s$   e Zd ZeeeedddZdS )LegacyTestdirPlugin)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(   r)   r     s   r   c                   @   sT   e Zd ZU dZeed< ddeeddddZdeee	d
ddZ
e	d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!   N)tmppath_factoryr"   r$   c                C   s   t | || _d S r%   )r   r   )r'   r   r"   r(   r(   r)   r*     s    zTempdirFactory.__init__T)basenamenumberedr$   c                 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   #  s    zTempdirFactory.mktempr+   c                 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   '  s    zTempdirFactory.getbasetemp)T)r   r   r   r   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eedddZeeee	dddZ
d	S )
LegacyTmpdirPluginsession)scope)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_factory)tmp_pathr$   c                 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'   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_makedirL  s    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_fspathT  s    r   c                 C   s
   t | jS )zThe 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_startdirY  s    r   c                 C   s   t t| jjS )zThe 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   Zinvocation_paramsdirr-   r(   r(   r)   Config_invocation_dirc  s    r   c                 C   s   t t| jS )zThe path to the :ref:`rootdir <rootdir>`.

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

    :type: LEGACY_PATH
    )r   r   Zrootpathr-   r(   r(   r)   Config_rootdirn  s    r   c                 C   s   | j rtt| j S dS )zThe 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   s
   t | jS )zThe 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  s    r   )rM   typevaluec                    s\   |dkrH| j d usJ | 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   r   ).0xZdpr(   r)   
<listcomp>      z/Config__getini_unknown_type.<locals>.<listcomp>zunknown configuration type: )r   parent
isinstancer   shlexsplit
ValueError)r'   rM   r   r   Zinput_valuesr(   r   r)   Config__getini_unknown_type  s    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$   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   sl   | j drht }| |j z
| j}W n ty:   Y n 0 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   )pluginmanagerr$   c                 C   s,   | | du }|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   )Cr   dataclassesr   r   pathlibr   typingr   r   r   r   Z	iniconfigr   Z_pytest.cacheproviderr   Z_pytest.compatr	   r
   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typing_extensionsr   Zpexpectr   r   	dataclassr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   objectr   r(   r(   r(   r)   <module>   sr    Y 


