bg- dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd lmZdd lmZdd lmZerddlmZedZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!m"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl'm(Z(ddl)m*Z*ddl)m+Z+ddl,m-Z-ee e.e/fZ0e!ej1Gdd Z2d!e e.fd"Z3d#e$d!dfd$Z4d%ed!dfd&Z5e*d'(d)e+d!e2fd*Z6d)e+d+e2d!efd,Z7e*d)e+d-e2d!e eddffd.Z8d/ee9e%ffd0Z:e&d1d12d3efd4Z;dS)5z>Support for providing temporary directories to test functions.N)Path)rmtree)Any)Dict) Generator)Optional) TYPE_CHECKING)Union)Item) CollectReport)StashKey)Literalallfailednone)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) MonkeyPatchceZdZUdZeeed<eed<eeed<eed<ded< dd d d eed ed ddeede ddf dZ e d d de de ddfdZ dedefdZddede defdZdefdZdS)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 _ispytestgiven_basetempretention_countretention_policybasetempr,returnct||d|_n>ttjt ||_||_||_||_ ||_ dSN) rr%rospathabspathstrr&r(r*r')selfr-r.r/tracer0r,s _/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/_pytest/tmpdir.py__init__zTempPathFactory.__init__;sm y!!!  !#'D $(N8K8K(L(L#M#MD  /!1!configcRt|t|d}|dkrtd|d|d}|dvrtd|d||jj|jd||d S) zTCreate a factory according to pytest configuration. :meta private: tmp_path_retention_countrz6tmp_path_retention_count must be >= 0. Current input: .tmp_path_retention_policyrzKtmp_path_retention_policy must be either all, failed, none. Current input: tmpdirT)r-r9r.r/r,)rintgetini ValueErroroptionr0r9get)clsr=r,countpolicys r: from_configzTempPathFactory.from_configRs y!!!FMM"<==>> 199QQQQ :;; 2 2 2g^dggg s!=1,""8,,!#     r<basenamectj|}||z j|krt |d|S)Nz& is not a normalized and relative path)r4r5normpath getbasetempresolveparentrE)r8rLs r:_ensure_relative_to_basetempz,TempPathFactory._ensure_relative_to_basetemprsj7##H--      ) 2 2 4 4 ;t?O?O?Q?Q Q QPPPQQ Qr<Tnumberedc$||}|s>||}|dn:t ||d}|d||S)aCreate 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)rootprefixrWmktemp)rRrOjoinpathmkdirrr&)r8rLrSps r:rZzTempPathFactory.mktempxs44X>> %  ""++H55A GGG    !t'7'7'9'9(QVWWWA KK! $ $ $r<c|j|jS|jV|j}|rt||d|}njt jd}t|ptj }tpd}| d|} |ddn<#t$r/| d }|ddYnwxYwt}|]|}|j|krtd |d |jd zd krt j||jdz|j}|jdkrd }t-d||t.d}| J|||_|d||S)zReturn the base temporary directory, creating it if needed. :returns: The base temporary directory. NrUrVPYTEST_DEBUG_TEMPROOTunknownz pytest-of-T)rWexist_okzpytest-of-unknownzThe temporary directory z: is not owned by the current user. Fix this and try again.?rirzpytest-)rYrXkeep lock_timeoutrWz new basetemp)r'r%existsrr\rPr4environrGrtempfile gettempdirget_userr[OSErrorrstatst_uidst_modechmodr(r*rrr&) r8r0from_envtemprootuserrootdiruid rootdir_statrcs r:rOzTempPathFactory.getbasetemps/ > %> !   ++H   h NNN & & &''))HHz~~&=>>HH=(;(=(=>>FFHHH::*D''(;T(;(;<SS sdd09T999999r<r$r1cd ddl}|S#ttf$rYdSwxYw)zlReturn the current user name, or None if getuser() does not work in the current environment (see #1010).rN)getpassgetuser ImportErrorKeyError)r~s r:ririsG    "tts //r=ct}||jt|d}||d|ddS)aCreate 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_cleanupundor$rKsetattr)r=mprs r:pytest_configurers^ B rw'33Fd3KKJJv*,=uJMMMMMr<parsercf|ddd|ddddS)Nr?zfHow many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.)helpdefaultrAzvControls which directories created by the `tmp_path` fixture are kept around, based on test outcome. (all/failed/none)r)addini)rs r:pytest_addoptionrsX MM" u  MM# r<session)scoperequestc|jjS)zGReturn a :class:`pytest.TempPathFactory` instance for the test session.)r=r)rs r:tmp_path_factoryrs > ++r<factoryc|jj}tjdd|}d}|d|}||dS)Nz[\W]_T)rS)nodenameresubrZ)rrrMAXVALs r:_mk_tmprsG < D 6'3 % %D F =D >>$> . ..r<rc#Kt||}|V|jjj}|j}|jjt}|dkr'|ddrt|d|jjt=dS)aUReturn 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. rcallT ignore_errorsN) rrr=rr*rstashtmppath_result_keyrGr)rrr5rJ result_dicts r:tmp_pathrs$ 7, - -D JJJ)0(>(P  /F,$%78K koofd;; t4(((( -...r< exitstatusc|jj}|j}|dS|j}|dkr2|dkr,|j%|rt |d|rt|dSdS)zAfter each session, remove base directory if all the tests passed, the policy is "failed", and the basetemp is not specified by a user. NrrTr)r=rr'r*r%is_dirrr)rrrr0rJs r:pytest_sessionfinishr%s)0(H)H  /Fa h    , 4 ??   1 84 0 0 0 0(h'''''((r<T)tryfirst hookwrapperitemc#KdV}|}i}|j|jt||j<dSr3) get_resultpassedr setdefaultrwhen)rroutcomeresultemptys r:pytest_runtest_makereportr>sLeeG#..00FEDJMDJ,e44V[AAAr<)rsDD  ))))))""""""5))))))34M-,,,,,!!!!!!&&&&&&333333******--------!!!!!!############------$$$$$$++++++++++++.Xd39o.00 [[[[[[[[| (3-     NV N N N N N V      y,n,,,,, /^/o/$//// / //>/tT4 /// /B(eCM.B((((2 4T***RDRRR+*RRRr<