
    	h-              
          d Z ddl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 erddlmZ ed         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!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ee.e/f                              Z0e!ej1         G d d                                   Z2d!ee.         fd"Z3d#e$d!dfd$Z4d%ed!dfd&Z5 e*d'(          d)e+d!e2fd*            Z6d)e+d+e2d!efd,Z7e*d)e+d-e2d!eeddf         fd.            Z8d/ee9e%f         fd0Z: e&d1d12          d3efd4            Z;dS )5z>Support for providing temporary directories to test functions.    N)Path)rmtree)Any)Dict)	Generator)Optional)TYPE_CHECKING)Union)Item)CollectReport)StashKey)Literalallfailednone)Parser   )LOCK_TIMEOUT)make_numbered_dir)make_numbered_dir_with_cleanup)rm_rf)cleanup_dead_symlinks)finalget_user_id)Config)ExitCode)hookimpl)check_ispytest)fixture)FixtureRequest)MonkeyPatchc                       e Zd ZU dZee         ed<   eed<   ee         ed<   eed<   ded<   	 dd	d
dee         dedddee         de	ddfdZ
ed	d
dede	dd fd            ZdedefdZddede	defdZdefdZdS )TempPathFactoryzFactory for temporary directories under the common base temp directory.

    The base directory can be configured using the ``--basetemp`` option.
    _given_basetemp_trace	_basetemp_retention_countRetentionType_retention_policyNF	_ispytestgiven_basetempretention_countretention_policybasetempr,   returnc                    t          |           |d | _        n>t          t          j                            t          |                              | _        || _        || _        || _	        || _
        d S N)r   r%   r   ospathabspathstrr&   r(   r*   r'   )selfr-   r.   r/   tracer0   r,   s          [/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/_pytest/tmpdir.py__init__zTempPathFactory.__init__;   sm     	y!!!!#'D  
 $(N8K8K(L(L#M#MD  /!1!    configc                R   t          |           t          |                    d                    }|dk     rt          d| d          |                    d          }|dvrt          d| d           | |j        j        |j                            d          ||d	
          S )zTCreate a factory according to pytest configuration.

        :meta private:
        tmp_path_retention_countr   z6tmp_path_retention_count must be >= 0. Current input: .tmp_path_retention_policyr   zKtmp_path_retention_policy must be either all, failed, none. Current input: tmpdirT)r-   r9   r.   r/   r,   )r   intgetini
ValueErroroptionr0   r9   get)clsr=   r,   countpolicys        r:   from_configzTempPathFactory.from_configR   s     	y!!!FMM"<==>>199QQQQ   :;;222g^dggg   s!=1,""8,,!#
 
 
 	
r<   basenamec                     t           j                            |          }|                                 |z                                  j        |                                 k    rt          | d          |S )Nz& is not a normalized and relative path)r4   r5   normpathgetbasetempresolveparentrE   )r8   rL   s     r:   _ensure_relative_to_basetempz,TempPathFactory._ensure_relative_to_basetempr   sj    7##H--)2244;t?O?O?Q?QQQPPPQQQr<   Tnumberedc                 $   |                      |          }|s>|                                                     |          }|                    d           n:t	          |                                 |d          }|                     d|           |S )a  Create a new temporary directory managed by the factory.

        :param basename:
            Directory base name, must be a relative path.

        :param numbered:
            If ``True``, ensure the directory is unique by adding a numbered
            suffix greater than any existing one: ``basename="foo-"`` and ``numbered=True``
            means that this function will create directories named ``"foo-0"``,
            ``"foo-1"``, ``"foo-2"`` and so on.

        :returns:
            The path to the new directory.
          mode)rootprefixrW   mktemp)rR   rO   joinpathmkdirr   r&   )r8   rL   rS   ps       r:   rZ   zTempPathFactory.mktempx   s     44X>> 	%  ""++H55AGGG!t'7'7'9'9(QVWWWAKK!$$$r<   c                    | j         | j         S | j        V| j        }|                                rt          |           |                    d           |                                }njt          j                            d          }t          |pt          j                                                              }t                      pd}|                    d|           }	 |                    dd           n<# t          $ r/ |                    d	          }|                    dd           Y nw xY wt                      }|]|                                }|j        |k    rt          d
| d          |j        dz  dk    rt          j        ||j        dz             | j        }| j        dk    rd}t-          d||t.          d          }|
J |            || _         |                     d|           |S )zReturn the base temporary directory, creating it if needed.

        :returns:
            The base temporary directory.
        NrU   rV   PYTEST_DEBUG_TEMPROOTunknownz
pytest-of-T)rW   exist_okzpytest-of-unknownzThe temporary directory z: is not owned by the current user. Fix this and try again.?   r   ir   zpytest-)rY   rX   keeplock_timeoutrW   znew basetemp)r'   r%   existsr   r\   rP   r4   environrG   r   tempfile
gettempdirget_userr[   OSErrorr   statst_uidst_modechmodr(   r*   r   r   r&   )	r8   r0   from_envtemprootuserrootdiruidrootdir_statrc   s	            r:   rO   zTempPathFactory.getbasetemp   s/    >%>!++H    hNNN&&&''))HHz~~&=>>HH=(;(=(=>>FFHHH::*D ''(;T(;(;<<G9548888 9 9 9"++,?@@54888889 --C&||~~&#--!27 2 2 2   !(50Q66HWl&:V&CDDD(D%//5 )  H ##X###!NH---s   (D   6D98D9r3   )T)__name__
__module____qualname____doc__r   r   __annotations__r   rC   boolr;   classmethodr   rK   r7   rR   rZ   rO    r<   r:   r$   r$   ,   s         
 d^###KKK~&&&& $("  " " " " " *	" 4." " 
" " " ". 
  	
 
 

 	

 

 
 
 [
>S S     s d d    09T 9 9 9 9 9 9r<   r$   r1   c                  d    	 ddl } |                                 S # t          t          f$ r Y dS w xY w)zlReturn the current user name, or None if getuser() does not work
    in the current environment (see #1010).r   N)getpassgetuserImportErrorKeyError)r~   s    r:   ri   ri      sG       "   tts    //r=   c                     t                      }|                     |j                   t                              | d          }|                    | d|d           dS )a  Create a TempPathFactory and attach it to the config object.

    This is to comply with existing plugins which expect the handler to be
    available at pytest_configure time, but ideally should be moved entirely
    to the tmp_path_factory session fixture.
    Tr+   _tmp_path_factoryF)raisingN)r"   add_cleanupundor$   rK   setattr)r=   mpr   s      r:   pytest_configurer      s^     
B
rw'33Fd3KKJJv*,=uJMMMMMr<   parserc                 f    |                      ddd           |                      ddd           d S )Nr?   zfHow many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.   )helpdefaultrA   zvControls which directories created by the `tmp_path` fixture are kept around, based on test outcome. (all/failed/none)r   )addini)r   s    r:   pytest_addoptionr      sX    
MM"u     MM#	      r<   session)scoperequestc                     | j         j        S )zGReturn a :class:`pytest.TempPathFactory` instance for the test session.)r=   r   )r   s    r:   tmp_path_factoryr      s     >++r<   factoryc                     | j         j        }t          j        dd|          }d}|d |         }|                    |d          S )Nz[\W]_   T)rS   )nodenameresubrZ   )r   r   r   MAXVALs       r:   _mk_tmpr      sG    <D6'3%%DF=D>>$>...r<   r   c              #     K   t          | |          }|V  | j        j        j        }|j        }| j        j        t                   }|dk    r'|                    dd          rt          |d           | j        j        t          = dS )aU  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.
    This behavior can be configured with :confval:`tmp_path_retention_count` and
    :confval:`tmp_path_retention_policy`.
    If ``--basetemp`` is used then it is cleared each session. See :ref:`base
    temporary directory`.

    The returned object is a :class:`pathlib.Path` object.
    r   callTignore_errorsN)
r   r   r=   r   r*   r   stashtmppath_result_keyrG   r   )r   r   r5   rJ   result_dicts        r:   tmp_pathr     s      $ 7,--D
JJJ )0(>(P/F,$%78Kkoofd;; 	t4((((-...r<   
exitstatusc                     | j         j        }|j        }|dS |j        }|dk    r2|dk    r,|j        %|                                rt          |d           |                                rt          |           dS dS )zAfter each session, remove base directory if all the tests passed,
    the policy is "failed", and the basetemp is not specified by a user.
    Nr   r   Tr   )r=   r   r'   r*   r%   is_dirr   r   )r   r   r   r0   rJ   s        r:   pytest_sessionfinishr   %  s     )0(H)H/Fah,4?? 	1 840000  (h'''''( (r<   T)tryfirsthookwrapperitemc              #      K   d V }|                                 }i }|j        | j                            t          |          |j        <   d S r3   )
get_resultpassedr   
setdefaultr   when)r   r   outcomeresultemptys        r:   pytest_runtest_makereportr   >  sL      eeG#..00FEDJMDJ,e44V[AAAr<   )<rx   dataclassesr4   r   rg   pathlibr   shutilr   typingr   r   r   r   r	   r
   _pytest.nodesr   _pytest.reportsr   _pytest.stashr   typing_extensionsr   r)   _pytest.config.argparsingr   r   r   r   r   r   _pytest.compatr   r   _pytest.configr   r   r   _pytest.deprecatedr   _pytest.fixturesr    r!   _pytest.monkeypatchr"   r7   rz   r   	dataclassr$   ri   r   r   r   r   r   rC   r   r   r|   r<   r:   <module>r      s   D D     				 				                                                              ) ) ) ) ) ) " " " " " " 5))))))34M - , , , , , ! ! ! ! ! ! & & & & & & 3 3 3 3 3 3       * * * * * * - - - - - - - - ! ! ! ! ! ! # # # # # # # # # # # # - - - - - - $ $ $ $ $ $ + + + + + + + + + + + +.Xd39o.00  [ [ [ [ [ [ [  [|	(3- 	 	 	 	
NV 
N 
N 
N 
N 
NV      	y,n , , , , ,/^ /o /$ / / / / 	///>/tT4 / / / 	/B(eCM.B ( ( ( (2 
4T***RD R R R +*R R Rr<   