o
    h@                     @  s2  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rd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#Z1dVd*d+Z2dWd-d.Z3dXd0d1Z4dYd3d4Z5dYd5d6Z6dZd8d9Z7d[d;d<Z8d\d@dAZ9d]dCdDZ:d^dFdGZ;edHdId_dKdLZ<ed`dNdOZ=edadTdUZ>dS )bz?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dddZ	e
dddZe
dddZe
dd Ze
dd Zejdd Ze
dddZdddZddd Zdd!d"Zdd#d$Zdd%d&Zdd'd(Zdd,d-Zdd.d/Zdd0d1Zdd2d3Zddd5d6Zdd7d8Zdd9d:Zddd;d<Zdd@dAZdBdC Z ddGdHZ!dIdJ Z"dKdL Z#dMdN Z$dOddPddRdSZ%ddUdVZ&ddWdXZ'ddYdZZ(dd[d\Z)dd^d_Z*d`da Z+ddbdcZ,ddgdhZ-e.j/e.j/efdidjZ0d4edkddldmZ1ddndoZ2dpdq Z3d4drddsdtZ4dddzd{Z5ddd}d~Z6dddZ7dddZ8d4S )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   r    boolreturnNonec                C     t | || _d S N)r   	_pytester)selfr!   r     r)   S/var/www/html/openai_agents/venv/lib/python3.10/site-packages/_pytest/legacypath.py__init__7   s   
zTestdir.__init__r	   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*   requestD      zTestdir.requestc                 C  r3   r&   r'   pluginsr.   r)   r)   r*   r8   H   r6   zTestdir.pluginsc                 C  s   || j _d S r&   r7   )r(   r8   r)   r)   r*   r8   L   r2   r   c                 C  r3   r&   )r'   _monkeypatchr.   r)   r)   r*   monkeypatchP   r6   zTestdir.monkeypatchr   c                 C     | j |S )z(See :meth:`Pytester.make_hook_recorder`.)r'   make_hook_recorder)r(   pluginmanagerr)   r)   r*   r<   T   r2   zTestdir.make_hook_recorderc                 C  
   | j  S )zSee :meth:`Pytester.chdir`.)r'   chdirr.   r)   r)   r*   r?   X      
zTestdir.chdirc                 C  r>   r&   )r'   	_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*   rF   _   s   zTestdir.makefilec                 C     t | j|S )z"See :meth:`Pytester.makeconftest`.)r   r'   makeconftestr(   sourcer)   r)   r*   rK   k      zTestdir.makeconftestc                 C  rJ   )zSee :meth:`Pytester.makeini`.)r   r'   makeinirL   r)   r)   r*   rO   o   rN   zTestdir.makeinirM   strr   c                 C  r;   )zSee :meth:`Pytester.getinicfg`.)r'   	getinicfgrL   r)   r)   r*   rQ   s   r2   zTestdir.getinicfgc                 C  rJ   )z'See :meth:`Pytester.makepyprojecttoml`.)r   r'   makepyprojecttomlrL   r)   r)   r*   rR   w   rN   zTestdir.makepyprojecttomlc                 O     t | jj|i |S )z See :meth:`Pytester.makepyfile`.)r   r'   
makepyfiler(   rH   rI   r)   r)   r*   rT   {      zTestdir.makepyfilec                 O  rS   )z!See :meth:`Pytester.maketxtfile`.)r   r'   maketxtfilerU   r)   r)   r*   rW      rV   zTestdir.maketxtfileNc                 C  r;   )z#See :meth:`Pytester.syspathinsert`.)r'   syspathinsertr(   r-   r)   r)   r*   rX      r2   zTestdir.syspathinsertc                 C  rJ   )zSee :meth:`Pytester.mkdir`.)r   r'   mkdirr(   namer)   r)   r*   rZ      rN   zTestdir.mkdirc                 C  rJ   )zSee :meth:`Pytester.mkpydir`.)r   r'   mkpydirr[   r)   r)   r*   r]      rN   zTestdir.mkpydirc                 C  rJ   )z"See :meth:`Pytester.copy_example`.)r   r'   copy_exampler[   r)   r)   r*   r^      rN   zTestdir.copy_exampleconfigr   Item | Collector | Nonec                 C     | j ||S )zSee :meth:`Pytester.getnode`.)r'   getnode)r(   r_   argr)   r)   r*   rb         zTestdir.getnodec                 C  r;   )z!See :meth:`Pytester.getpathnode`.)r'   getpathnoderY   r)   r)   r*   re      r2   zTestdir.getpathnodecolitemslist[Item | Collector]
list[Item]c                 C  r;   )zSee :meth:`Pytester.genitems`.)r'   genitems)r(   rf   r)   r)   r*   ri      r2   zTestdir.genitemsc                 C  r;   )zSee :meth:`Pytester.runitem`.)r'   runitemrL   r)   r)   r*   rj      r2   zTestdir.runitemc                 G  s   | j j|g|R  S )z&See :meth:`Pytester.inline_runsource`.)r'   inline_runsource)r(   rM   cmdlineargsr)   r)   r*   rk         zTestdir.inline_runsourcec                 G     | j j| S )z%See :meth:`Pytester.inline_genitems`.)r'   inline_genitemsr(   rH   r)   r)   r*   ro      r2   zTestdir.inline_genitemsr)   r8   no_reraise_ctrlcrr   c                G     | j j|||dS )z See :meth:`Pytester.inline_run`.rq   )r'   
inline_run)r(   r8   rr   rH   r)   r)   r*   rt      s   zTestdir.inline_runr   c                 O     | j j|i |S )z)See :meth:`Pytester.runpytest_inprocess`.)r'   runpytest_inprocessrU   r)   r)   r*   rv         zTestdir.runpytest_inprocessc                 O  ru   )zSee :meth:`Pytester.runpytest`.)r'   	runpytestrU   r)   r)   r*   rx      rw   zTestdir.runpytestc                 G  rn   )z!See :meth:`Pytester.parseconfig`.)r'   parseconfigrp   r)   r)   r*   ry      r2   zTestdir.parseconfigc                 G  rn   )z$See :meth:`Pytester.parseconfigure`.)r'   parseconfigurerp   r)   r)   r*   rz      r2   zTestdir.parseconfigure	test_funcc                 C  ra   )zSee :meth:`Pytester.getitem`.)r'   getitem)r(   rM   funcnamer)   r)   r*   r|      rd   zTestdir.getitemc                 C  r;   )zSee :meth:`Pytester.getitems`.)r'   getitemsrL   r)   r)   r*   r~      r2   zTestdir.getitemsc                 C  s   | j j|||dS )z"See :meth:`Pytester.getmodulecol`.)
configargswithinit)r'   getmodulecol)r(   rM   r   r   r)   r)   r*   r      s   zTestdir.getmodulecolmodcolr   r\   c                 C  ra   )z%See :meth:`Pytester.collect_by_name`.)r'   collect_by_name)r(   r   r\   r)   r)   r*   r      rd   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  rs   )zSee :meth:`Pytester.run`.r   )r'   run)r(   r   r   r   r)   r)   r*   r      rm   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   rH   r)   r)   r*   r      rw   zTestdir.runpytest_subprocess      $@stringexpect_timeoutfloatpexpect.spawnc                 C     | j j||dS )z"See :meth:`Pytester.spawn_pytest`.r   )r'   spawn_pytest)r(   r   r   r)   r)   r*   r      rN   zTestdir.spawn_pytestcmdc                 C  r   )zSee :meth:`Pytester.spawn`.r   )r'   spawn)r(   r   r   r)   r)   r*   r      rN   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&   )rP   r/   r.   r)   r)   r*   __str__   rC   zTestdir.__str__)r!   r   r    r"   r#   r$   r#   r	   )r#   r   )r#   r   )r#   r$   )rM   rP   r#   r   r&   )r_   r   r#   r`   )rf   rg   r#   rh   )rr   r"   )r#   r   )r#   r   )r{   )r)   F)r   r   r\   rP   r#   r`   )r   )r   rP   r   r   r#   r   )r   rP   r   r   r#   r   )r#   rP   )9__name__
__module____qualname____doc____test__r   r   __annotations__r   r+   propertyr/   r1   r5   r8   setterr:   r<   r?   rB   rF   rK   rO   rQ   rR   rT   rW   rX   rZ   r]   r^   rb   re   ri   rj   rk   ro   rt   rv   rx   ry   rz   r|   r~   r   r   
subprocessPIPEr   r   r   r   r   r   r   r   r   r)   r)   r)   r*   r   )   sv   
 


























r   c                   @  s   e Zd Zee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#   r   )r   r   r   staticmethodr   r   r)   r)   r)   r*   r      s    r   c                   @  s@   e Zd ZU dZded< dddddZddddZ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   tmppath_factoryr    r"   r#   r$   c                C  r%   r&   )r   r   )r(   r   r    r)   r)   r*   r+     s   
zTempdirFactory.__init__TbasenamerP   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     rV   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   #  rw   zTempdirFactory.getbasetempN)r   r   r    r"   r#   r$   )T)r   rP   r   r"   r#   r	   r   )r   r   r   r   r   r+   r   r   r)   r)   r)   r*   r   
  s   
 
r   c                   @  s6   e Zd ZeedddddZeedddZdS )LegacyTmpdirPluginsession)scoper5   r   r#   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_pathr   r	   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)r5   r   r#   r   )r   r   r#   r	   )r   r   r   r   r   r   r/   r)   r)   r)   r*   r   (  s    r   r(   r   r\   rP   r#   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   rZ   r[   r)   r)   r*   Cache_makedirC  s   r   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_fspathK  r@   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   	startpathr.   r)   r)   r*   TerminalReporter_startdirP     
r   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   rP   invocation_paramsdirr.   r)   r)   r*   Config_invocation_dirZ  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   rP   rootpathr.   r)   r)   r*   Config_rootdire  s   r   LEGACY_PATH | Nonec                 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   rP   r.   r)   r)   r*   Config_inifileo  s   r   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_startdiry  r   r   typevaluestr | list[str]c                   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   rP   ).0xdpr)   r*   
<listcomp>  s    z/Config__getini_unknown_type.<locals>.<listcomp>zunknown configuration type: )r   parent
isinstancerP   shlexsplit
ValueError)r(   r\   r   r   input_valuesr)   r   r*   Config__getini_unknown_type  s   r   r   c                 C  r   )z4(deprecated) returns a legacy_path copy of self.pathr   r.   r)   r)   r*   Node_fspath  r@   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objectmanagerr   c                 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   )r(   r   r\   rP   r#   r	   )r(   r   r#   r	   )r(   r   r#   r	   )r(   r   r#   r	   )r(   r   r#   r   )r(   r   r#   r	   )r\   rP   r   rP   r   r   )r(   r   r#   r	   )r(   r   r   r	   r#   r$   )r   r   r#   r$   )r_   r   r#   r$   )r   r   r   r   r#   r$   )?r   
__future__r   dataclassespathlibr   r   r   typingr   r   r   	iniconfigr   _pytest.cacheproviderr   _pytest.compatr	   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   pexpectr   r   	dataclassr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r)   r)   r)   r*   <module>   sn    T













