o
    ZhA                  	   @   s  d 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' ddl%m(Z( ddl)m*Z* ddl+m,Z, erddl-Z-eG dd dZ.G d d! d!Z/eej0G d"d# d#Z1G d$d% d%Z2d&ed'e3d(efd)d*Z4d&ed(efd+d,Z5d&e*d(efd-d.Z6d&ed(efd/d0Z7d&ed(efd1d2Z8d&ed(e
e fd3d4Z9d&ed(efd5d6Z:d'e3d7e3d8ee3e	e3 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dGe@dHed(dfdIdJZAdS )Kz?Add backward compatibility support for the legacy py path type.    N)Path)Final)final)List)Optional)TYPE_CHECKING)Union)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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)   I/var/www/html/lang_env/lib/python3.10/site-packages/_pytest/legacypath.py__init__8   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'   Z_test_tmprootr.   r)   r)   r*   test_tmprootA      zTestdir.test_tmprootc                 C      | j jS r&   )r'   _requestr.   r)   r)   r*   requestE      zTestdir.requestc                 C   r2   r&   r'   pluginsr.   r)   r)   r*   r7   I   r5   zTestdir.pluginsc                 C   s   || j _d S r&   r6   )r(   r7   r)   r)   r*   r7   M   r1   c                 C   r2   r&   )r'   Z_monkeypatchr.   r)   r)   r*   monkeypatchQ   r5   zTestdir.monkeypatchc                 C      | j |S )z(See :meth:`Pytester.make_hook_recorder`.)r'   make_hook_recorder)r(   pluginmanagerr)   r)   r*   r:   U   r1   zTestdir.make_hook_recorderc                 C   
   | j  S )zSee :meth:`Pytester.chdir`.)r'   chdirr.   r)   r)   r*   r=   Y      
zTestdir.chdirc                 C   r<   r&   )r'   Z	_finalizer.   r)   r)   r*   finalize]      
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*   rC   `   s   zTestdir.makefilec                 C      t | j|S )z"See :meth:`Pytester.makeconftest`.)r   r'   makeconftestr(   sourcer)   r)   r*   rH   l      zTestdir.makeconftestc                 C   rG   )zSee :meth:`Pytester.makeini`.)r   r'   makeinirI   r)   r)   r*   rL   p   rK   zTestdir.makeinirJ   c                 C   r9   )zSee :meth:`Pytester.getinicfg`.)r'   	getinicfgrI   r)   r)   r*   rM   t   r1   zTestdir.getinicfgc                 C   rG   )z'See :meth:`Pytester.makepyprojecttoml`.)r   r'   makepyprojecttomlrI   r)   r)   r*   rN   x   rK   zTestdir.makepyprojecttomlc                 O      t | jj|i |S )z See :meth:`Pytester.makepyfile`.)r   r'   
makepyfiler(   rE   rF   r)   r)   r*   rP   |      zTestdir.makepyfilec                 O   rO   )z!See :meth:`Pytester.maketxtfile`.)r   r'   maketxtfilerQ   r)   r)   r*   rS      rR   zTestdir.maketxtfilec                 C   r9   )z#See :meth:`Pytester.syspathinsert`.)r'   syspathinsertr(   r-   r)   r)   r*   rT      r1   zTestdir.syspathinsertc                 C   rG   )zSee :meth:`Pytester.mkdir`.)r   r'   mkdirr(   namer)   r)   r*   rV      rK   zTestdir.mkdirc                 C   rG   )zSee :meth:`Pytester.mkpydir`.)r   r'   mkpydirrW   r)   r)   r*   rY      rK   zTestdir.mkpydirc                 C   rG   )z"See :meth:`Pytester.copy_example`.)r   r'   copy_examplerW   r)   r)   r*   rZ      rK   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   r9   )z!See :meth:`Pytester.getpathnode`.)r'   getpathnoderU   r)   r)   r*   r`      r1   zTestdir.getpathnodecolitemsc                 C   r9   )zSee :meth:`Pytester.genitems`.)r'   genitems)r(   ra   r)   r)   r*   rb      r1   zTestdir.genitemsc                 C   r9   )zSee :meth:`Pytester.runitem`.)r'   runitemrI   r)   r)   r*   rc      r1   zTestdir.runitemc                 G   s   | j j|g|R  S )z&See :meth:`Pytester.inline_runsource`.)r'   inline_runsource)r(   rJ   Zcmdlineargsr)   r)   r*   rd         zTestdir.inline_runsourcec                 G      | j j| S )z%See :meth:`Pytester.inline_genitems`.)r'   inline_genitemsr(   rE   r)   r)   r*   rg      r1   zTestdir.inline_genitemsr)   r7   no_reraise_ctrlcrj   c                G      | j j|||dS )z See :meth:`Pytester.inline_run`.ri   )r'   
inline_run)r(   r7   rj   rE   r)   r)   r*   rl      s   zTestdir.inline_runc                 O      | j j|i |S )z)See :meth:`Pytester.runpytest_inprocess`.)r'   runpytest_inprocessrQ   r)   r)   r*   rn         zTestdir.runpytest_inprocessc                 O   rm   )zSee :meth:`Pytester.runpytest`.)r'   	runpytestrQ   r)   r)   r*   rp      ro   zTestdir.runpytestc                 G   rf   )z!See :meth:`Pytester.parseconfig`.)r'   parseconfigrh   r)   r)   r*   rq      r1   zTestdir.parseconfigc                 G   rf   )z$See :meth:`Pytester.parseconfigure`.)r'   parseconfigurerh   r)   r)   r*   rr      r1   zTestdir.parseconfigure	test_funcc                 C   r\   )zSee :meth:`Pytester.getitem`.)r'   getitem)r(   rJ   funcnamer)   r)   r*   rt      r_   zTestdir.getitemc                 C   r9   )zSee :meth:`Pytester.getitems`.)r'   getitemsrI   r)   r)   r*   rv      r1   zTestdir.getitemsc                 C   s   | j j|||dS )z"See :meth:`Pytester.getmodulecol`.)
configargswithinit)r'   getmodulecol)r(   rJ   rw   rx   r)   r)   r*   ry      s   zTestdir.getmodulecolmodcolrX   c                 C   r\   )z%See :meth:`Pytester.collect_by_name`.)r'   collect_by_name)r(   rz   rX   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   rk   )zSee :meth:`Pytester.run`.r   )r'   run)r(   r   r   r}   r)   r)   r*   r      re   zTestdir.runc                 C   r9   )zSee :meth:`Pytester.runpython`.)r'   	runpython)r(   scriptr)   r)   r*   r      r1   zTestdir.runpythonc                 C   r9   )z!See :meth:`Pytester.runpython_c`.)r'   runpython_c)r(   commandr)   r)   r*   r      r1   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   rE   r)   r)   r*   r      ro   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      rK   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__   r@   zTestdir.__str__)r$   Nr&   )rs   )r)   F)r   )G__name__
__module____qualname____doc__Z__test__r   r   __annotations__r    boolr+   propertyr   r/   r0   r4   r7   setterr   r8   r   r:   r=   r?   rC   rH   rL   r   r	   rM   rN   rP   rS   rT   rV   rY   rZ   r   r   r   r   r   r]   r`   r   rb   rc   rd   rg   rl   r   rn   rp   rq   rr   rt   rv   ry   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 ``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 )zOSame as :meth:`TempPathFactory.mktemp`, but returns a ``py.path.local`` object.)r   r   mktempresolve)r(   r   r   r)   r)   r*   r   $  rR   zTempdirFactory.mktempc                 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   (  ro   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)scoper4   r$   c                 C   r2   )zFReturn a :class:`pytest.TempdirFactory` instance for the test session.)r[   _tmpdirhandler)r4   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:`temporary directory location and retention`.

        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/   5  s   zLegacyTmpdirPlugin.tmpdirN)r   r   r   r   r   r   r   r   r   r   r/   r)   r)   r)   r*   r   -  s    r   r(   rX   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   rV   rW   r)   r)   r*   Cache_makedirM  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_fspathU  r>   r   c                 C   r   )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_startdirZ     
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_dird  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_rootdiro  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_inifiley  s   r   c                 C   r   )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  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| |)NZpathlistc                    s   g | ]
}t t | qS r)   )r   r   ).0xZdpr)   r*   
<listcomp>  s    z/Config__getini_unknown_type.<locals>.<listcomp>zunknown configuration type: )r   parent
isinstancer   shlexsplit
ValueError)r(   rX   r   r   Z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)Z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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   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;   Z
has_pluginr   r   r   Z_tmp_path_factoryAttributeErrorr   r   registerr   )r[   r   Z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)Z
get_pluginZis_registeredr   r   )r   r   Zis_pytesterr)   r)   r*   pytest_plugin_registered  s   r   )Br   dataclassespathlibr   r   r   typingr   r   r   r   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   objectr   r)   r)   r)   r*   <module>   s~    X 




