
    ~/j3                    \   S r SSKJr  SSKrSSKJr  SSKJr  SSKrSSK	r	SSK
Jr  SSKrSSKJr  SSKrSSKrSSKJr  SS	KJr  SS
KJr  SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  SSKJr  SSKJr  SSKJr  SSKJr  SSK J!r!  SSK"J#r#  SSK$J%r%  SSK$J&r&  SSK'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.  \.\/\0\14      " 5       r2\S   r3\\Rh                   " S S5      5       5       r5S,S  jr6S-S! jr7S.S" jr8\%" S#S$9S/S% j5       r9S0S& jr:\%      S1S' j5       r;S2S( jr<\" S)S)S*9    S3S+ j5       r=g)4z>Support for providing temporary directories to test functions.    )annotationsN)	Generator)	ExitStack)Path)rmtree)Any)final)Literal   )cleanup_dead_symlinks)LOCK_TIMEOUT)make_numbered_dir)make_numbered_dir_with_cleanup)rm_rf)get_user_id)Config)ExitCode)hookimpl)Parser)check_ispytest)fixture)FixtureRequest)MonkeyPatch)Item)
TestReport)StashKeyallfailednonec                      \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S
\S'    SSS.           SS jjjr\SS.     SS jj5       rSS jr	SSS jjr
SS jrSrg)TempPathFactory+   zFactory for temporary directories under the common base temp directory,
as discussed at :ref:`temporary directory location and retention`.
Path | None_given_basetempr   _trace	_basetempint_retention_countRetentionType_retention_policyNF	_ispytestc                   [        U5        Uc  S U l        O6[        [        R                  R                  [        U5      5      5      U l        X@l        X l        X0l	        XPl
        [        5       U l        g N)r   r%   r   ospathabspathstrr&   r)   r+   r'   r   _exit_stack)selfgiven_basetempretention_countretention_policytracebasetempr-   s          M/root/lseg-credit/backend/venv/lib/python3.13/site-packages/_pytest/tmpdir.py__init__TempPathFactory.__init__9   s]     	y!!#'D 
 $(N8K(L#MD  /!1! %;    c               0   [        U5        [        UR                  S5      5      nUS:  a  [        SU S35      eUR                  S5      nUS;  a  [        SU S35      eU " UR                  R
                  UR                  R                  S5      UUS	S
9$ )zDCreate 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)r6   r9   r7   r8   r-   )r   r(   getini
ValueErroroptionr:   r9   get)clsconfigr-   countpolicys        r;   from_configTempPathFactory.from_configS   s     	y!FMM"<=>19HqQ  :;22]^d]eefg  !==11,,""8,!#
 	
r>   c                    [         R                  R                  U5      nU R                  5       U-  R	                  5       R
                  U R                  5       :w  a  [        U S35      eU$ )Nz& is not a normalized and relative path)r0   r1   normpathgetbasetempresolveparentrE   )r5   basenames     r;   _ensure_relative_to_basetemp,TempPathFactory._ensure_relative_to_basetemps   s\    77##H-)224;;t?O?O?QQz)OPQQr>   c                    U R                  U5      nU(       d0  U R                  5       R                  U5      nUR                  SS9  U$ [	        U R                  5       USS9nU R                  SU5        U$ )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prefixrY   mktemp)rT   rP   joinpathmkdirr   r&   )r5   rS   numberedps       r;   r\   TempPathFactory.mktempy   sr     44X>  "++H5AGGG  "t'7'7'9(QVWAKK!$r>   c           	        U R                   b  U R                   $ U R                  bM  U R                  nUR                  5       (       a  [        U5        UR	                  SS9  UR                  5       nGO#[        R                  R                  S5      n[        U=(       d    [        R                  " 5       5      R                  5       n[        5       =(       d    SnUR                  SU 35      n UR	                  SSS9  [        5       nUb  [        R                   [        R"                  ;   a  S	OSnUR!                  US
9n[         R$                  " UR&                  5      (       a  [        SU S35      eUR(                  U:w  a  [        SU S35      eUR&                  S-  S:w  aC  [        R*                  [        R"                  ;   a  S	OSn	UR+                  UR&                  S-  U	S
9  U R,                  n
U R.                  S:X  a  Sn
[1        SUU
[2        SU R4                  R6                  S9n[8        R:                  " U R4                  R<                  5        U R4                  R7                  [8        R>                  U R4                  R<                  5        Uc   U5       eXl         U RA                  SU5        U$ ! [         a%    UR                  S5      nUR	                  SSS9   GNf = f)ziReturn the base temporary directory, creating it if needed.

:returns:
    The base temporary directory.
rW   rX   PYTEST_DEBUG_TEMPROOTunknownz
pytest-of-T)rY   exist_okzpytest-of-unknownF)follow_symlinkszThe temporary directory z, is a symbolic link. Fix this and try again.z: is not owned by the current user. Fix this and try again.?   r   ir    zpytest-)r[   rZ   keeplock_timeoutrY   registerznew basetemp)!r'   r%   existsr   r^   rQ   r0   environrG   r   tempfile
gettempdirget_userr]   OSErrorr   statsupports_follow_symlinksS_ISLNKst_modest_uidchmodr)   r+   r   r   r4   callbackatexitrj   close
unregisterr&   )r5   r:   from_envtemprootuserrootdiruidstat_follow_symlinksrootdir_statchmod_follow_symlinksrh   s              r;   rP   TempPathFactory.getbasetemp   s    >>%>>!+++H  hNNN&'')Hzz~~&=>HH=(;(;(=>FFHH:*D ''*TF(;<G9548$ -CWW(C(CCE %  '||<P|Q<< 4 455!27) <2 2   &&#-!27) <2 2  !((50Q6!#R-H-H!Hd * MM$,,v5(= "  ((D%%/5 )))22H OOD,,223%%f&7&79I9I9O9OP#-X-#!NH-y  9"++,?@5489s   0J; ;+K*)K*)r'   r4   r%   r)   r+   r&   r/   )r6   r$   r7   r(   r8   r*   r:   r$   r-   boolreturnNone)rI   r   r-   r   r   r"   )rS   r3   r   r3   )T)rS   r3   r_   r   r   r   )r   r   )__name__
__module____qualname____firstlineno____doc____annotations__r<   classmethodrL   rT   r\   rP   __static_attributes__ r>   r;   r"   r"   +   s     ! K$$ !%'  '#' ' (	' ' ' 
'4 
  	

 	

 

 
>0Tr>   r"   c                 b     SSK n U R                  5       $ ! [        [        [        4 a     gf = f)zhReturn the current user name, or None if getuser() does not work
in the current environment (see #1010).r   N)getpassgetuserImportErrorrp   KeyError)r   s    r;   ro   ro      s0      (+ s    ..c                    [        5       nU R                  UR                  5        [        R	                  U SS9nUR                  U SUSS9  g)zCreate 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"   rL   setattr)rI   mpr   s      r;   pytest_configurer      sI     
B
rww'33Fd3KJJv*,=uJMr>   c                L    U R                  SSSSS9  U R                  SSSSS	9  g )
Nr@   zfHow many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.3string)helpdefaulttyperB   zvControls which directories created by the `tmp_path` fixture are kept around, based on test outcome. (all/failed/none)r   )r   r   r   )addini)parsers    r;   pytest_addoptionr     s@    
MM"u   MM#  r>   session)scopec                .    U R                   R                  $ )zGReturn a :class:`pytest.TempPathFactory` instance for the test session.)rI   r   )requests    r;   tmp_path_factoryr     s     >>+++r>   c                    U R                   R                  n[        R                  " SSU5      nSnUS U nUR	                  USS9$ )Nz[\W]_   T)r_   )nodenameresubr\   )r   factoryr   MAXVALs       r;   _mk_tmpr     sF    <<D66'3%DF=D>>$>..r>   c              #     #    [        X5      nUv   UR                  nU R                  R                  [           nUS:X  a!  UR                  SS5      (       a
  [        USS9  U R                  R                  [        	 g7f)a'  Return a temporary directory (as :class:`pathlib.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`.
r   callTignore_errorsN)r   r+   r   stashtmppath_result_keyrG   r   )r   r   r1   rK   result_dicts        r;   tmp_pathr   "  so      7-D
J //F,,$$%78Kkoofd;; 	t4(-.s   A<A>c                L   U R                   R                  nUR                  nUc  gUR                  nUS:X  a2  US:X  a,  UR                  c  UR                  5       (       a
  [        USS9  UR                  5       (       a  [        U5        UR                  R                  5         g)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   )
rI   r   r'   r+   r%   is_dirr   r   r4   ry   )r   
exitstatusr   r:   rK   s        r;   pytest_sessionfinishr   ;  s     )0(H(H))H//Fah,,4?? 840 h'   &&(r>   T)wrappertryfirstc              #     #    S v nUR                   c   e0 nUR                  U R                  R                  [        U5      UR                   '   U$ 7fr/   )whenpassedr   
setdefaultr   )itemr   repemptys       r;   pytest_runtest_makereportr   W  sJ      C88EADDJJ,e4SXX>Js   AA)r   z
str | None)rI   r   r   r   )r   r   r   r   )r   r   r   r"   )r   r   r   r"   r   r   )r   r   r   r"   r   zGenerator[Path])r   zint | ExitCode)r   r   r   z'Generator[None, TestReport, TestReport])>r   
__future__r   rx   collections.abcr   
contextlibr   dataclassesr0   pathlibr   r   shutilr   rq   rm   typingr   r	   r
   r   r   r   r   r   _pytest.compatr   _pytest.configr   r   r   _pytest.config.argparsingr   _pytest.deprecatedr   _pytest.fixturesr   r   _pytest.monkeypatchr   _pytest.nodesr   _pytest.reportsr   _pytest.stashr   dictr3   r   r   r*   	dataclassr"   ro   r   r   r   r   r   r   r   r   r>   r;   <module>r      s=   D "  %    	  	       * ! & 3  & ! # # , - $ + +  & " d39o.0 /0 x x  xv	
N$ 	y, ,/ 	///>// 	/0)8 
$&
, 'r>   