bgd xddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZdd lmZddl mZddl m!Z!ddl m"Z"ddl m#Z#ddl m$Z$ddl m%Z%ddl m&Z&ddl m'Z'ddl m(Z(ddl m)Z)ddl m*Z*ddl m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1dZ2e*deZ3eeeefZ4d Z5d!Z6d"e3d#e3fd$Z7d"e8d%e+e9e(e)e9e9e&e j:ffd&ed#e;fd'Zd"ed#dfd*Z?d+ed,e8d#e$efd-Z@d.e#ed,e8d#e$e8fd/ZAd+ed,e8d#e$e8fd0ZBd#eCfd1ZDd+ed2e+e8efd3e+e8efd#dfd4ZEdld+ed,e8d6eCd#efd7ZFd8ed#efd9ZGejHfd:efd;ZId"ed#dfd<ZJd"ed=eKd#e;fd>ZLd"ed=eKd#dfd?ZMd+ed,e8d@eCd#e$efdAZNd+efdBZOd+ed,e8d@eCd=eKd#df dCZPd+ed,e8d@eCdDeKd6eCd#ef dEZQdFe8dGed#efdHZRdIe8d"e+e8dJfd#e;fdKZSdLe8d#e'e8fdMZTdNZUGdOdPe ZVGdQdReWZXeVjYdSd8e+e8dJfd6e+e8eVfd+ed#efdTZZej[\dUr dVe8dWe8d#e;fdXZ]n dVe8dWe8d#e;fdYZ]d"ed+ed#e8fdZZ^d[e"e8efd\e8d#dfd]Z_d"ed#e&efd^Z`d"e+e8dJfd#e%d_fd`Zad"e+e8dJfdae!d_ge;fd#e$d_fdbZbd"e+ee8fd#efdcZcddedeed#e&efdfZddgedhed#e8fdiZedjed2ed#dfdkZfdS)mN)Enum)EBADF)ELOOP)ENOENT)ENOTDIR)partial) expanduser) expandvars)isabs)sep)Path)PurePath) ModuleType)Callable)Dict)Iterable)Iterator)List)Optional)Set)Tuple)Type)TypeVar)Union) assert_never)skip) PytestWarningi _AnyPurePath)bound)icbt|ddtvpt|ddtvS)Nerrnowinerror)getattr_IGNORED_ERRORS_IGNORED_WINERRORS) exceptions `/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/_pytest/pathlib.py _ignore_errorr);s6 7D))_< F 9j$ / /3E Epathreturnc,|dS)Nz.lock)joinpathr+s r( get_lock_pathr0Bs == ! !!r*excinfo start_pathc  t|tr|}n|d}t|trdSt|ts9t jt d|dt|d|dS|tj tj tj fvrU|tj fvrDt jt d ||t||dSddld td dffd }t!|}|r*|jD]"}|t|||krn#|t|||d S) zhHandle known read-only errors during rmtree. The returned value is used only by our own tests. Fz(rm_rf) error removing  z: z4(rm_rf) unknown function {} when removing {}: {}: {}rNpr,ctj|j}tj||jzjzdSN)osstatst_modechmodS_IRUSRS_IWUSR)r6moder:s r(chmod_rwz on_rm_rf_error..chmod_rwrs9wqzz! D4<'$,677777r*T) isinstance BaseExceptionFileNotFoundErrorPermissionErrorwarningswarnrtyper9rmdirremoveunlinkopenformatr:strr is_fileparents) funcr+r1r2excr@r6parentr:s @r(on_rm_rf_errorrSFs'=))aj#())u c? + + NDNNDIINNNN O O   u BHbi333 z ! ! MKRRdDIIs   uKKK8C8D888888 T Ayy{{i  F HS[[ ! ! !##$ HSYYDJJJ 4r*ctjdr=|}t t t |}|S)a0Get the extended-length version of a path (Windows). On Windows, by default, the maximum length of a path (MAX_PATH) is 260 characters, and operations on paths longer than that fail. But it is possible to overcome this by converting the path to "extended-length" form before performing the operation: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation On Windows, this function returns the extended-length absolute version of path. On other platforms it returns path unchanged. win32)sysplatform startswithresolver get_extended_length_path_strrMr/s r(ensure_extended_length_pathr[sJ |w''=||~~0T;;<< Kr*cd}d}|||fr|S|dr ||ddzS||zS)z1Convert a path to a Windows extended length path.z\\?\z\\?\UNC\z\\N)rX)r+long_path_prefixunc_long_path_prefixs r(rZrZs` ) (*>?@@  v/#d122h.. d ""r*ct|}tt|}tjdkr%t jt||dSt jt||dS)zNRemove the path contents recursively, even if some elements are read-only.)r2) )onexc)onerrorN)r[rrSrV version_infoshutilrmtreerM)r+rds r(rm_rfrhss 't , ,Dn666G 7"" c$iiw////// c$ii111111r*rootprefixc#K|}|D]2}|j|r|V3dS)zGFind all elements in root that begin with the prefix, case insensitive.N)loweriterdirnamerX)rirjl_prefixxs r( find_prefixedrqs^||~~H \\^^ 6<<>> $ $X . . GGGr*iterc#TKt|}|D]}|j|dVdS)zReturn the parts of the paths following the prefix. :param iter: Iterator over path names. :param prefix: Expected prefix of the path names. N)lenrn)rrrjp_lenr6s r(extract_suffixesrvsE KKE fUVVnr*c>tt|||S)z+Combine find_prefixes and extract_suffixes.)rvrq)rirjs r( find_suffixesrxs M$77 @ @@r*cD t|S#t$rYdSwxYw)z0Parse number path suffixes, returns -1 on error.)int ValueError) maybe_nums r( parse_numr~s59~~ rrs  targetlink_toc||} |n#t$rYnwxYw ||dS#t$rYdSwxYw)aHelper to create the current symlink. It's full of race conditions that are reasonably OK to ignore for the context of best effort linking to the latest test run. The presumption being that in case of much parallelism the inaccuracy is going to be acceptable. N)r.rJOSError symlink_to Exception)rirrcurrent_symlinks r(_force_symlinkrsmmF++O           ""7+++++      s, 99A A"!A"r?c tdD]}tttt ||d}|dz}|||} ||t||dz||cS#t$rYwxYwtd ||) zKCreate a directory with an increased number as suffix for the given prefix. rzdefaultr4r?currentzKcould not create numbered dir with prefix {prefix} in {root} after 10 tries)rjri) rangemaxmapr~rxr.mkdirrrrrL)rirjr?i max_existing new_numbernew_paths r(make_numbered_dirrs 2YY  3y-f*E*EFFPRSSS !A% ==F!8J!8!899  NNN % % % 4)!3X > > >OOO     D   006f40P0P   s#B BBr6ct|} tjt|tjtjztjzd}tj}t|}tj ||tj || std|S#t$r}td||d}~wwxYw)z2Create a lock to prevent premature folder cleanup.iz/lock path got renamed after successful creationzcannot create lockfile in N)r0r9rKrMO_WRONLYO_CREATO_EXCLgetpidencodewritecloserNrFileExistsError)r6 lock_pathfdpidspides r(create_cleanup_lockrsa  I  WS^^R[2:%= %I5 Q Qikk3xx   T    "" MKLL L ???616677Q>?sAC C<$C77C<rcltj}||fdtdtddfd}||S)zFRegister a cleanup function for removing a lock, by default on atexit.r original_pidr,Nctj}||krdS |dS#t$rYdSwxYwr8)r9rrJr)rr current_pids r(cleanup_on_exitz6register_cleanup_lock_removal..cleanup_on_exits\ikk , & & F             DD s3 AA)r9rr r{)rregisterrrs r(register_cleanup_lock_removalr sS )++C*343QU 8O $ $$r*ct|}d} t|}|j}|dt j}||t|n;#t$r.Y|( | dS#t$rYdSwxYwdSwxYw |( | dS#t$rYdSwxYwdS#|& | w#t$rYwwxYwwxYw)z^Remove a numbered directory if its lock can be obtained and it does not seem to be in use.Nzgarbage-) r[rrRr.uuiduuid4renamerhrrJ)r+rrRgarbages r(maybe_delete_a_numbered_dirrsy 't , ,DI'-- //";TZ\\";";<< G g       """""     !       """""     ! 9    """"     !srA#A76C7 B/CB B)(B).B//C6C CCD #C87D 8 DD DD $consider_lock_dead_if_created_beforec|rdSt|} |sdSn#t$rYdSwxYw |j}||krGt jt5| ddddS#1swxYwYdS#t$rYdSwxYw)zGCheck if `path` is deletable based on whether the lock file is expired.FTN) is_symlinkr0rNrr:st_mtime contextlibsuppressrJr)r+rlock lock_times r(ensure_deletabler7s4 u   D||~~ 4  uu IIKK(  ; ; ; $W--                   u uus3> A  A B8B++B/2B/8 CCcHt||rt|dSdS)z8Try to cleanup a folder if we can ensure it's deletable.N)rr)r+rs r( try_cleanuprSs3BCC*#D)))))**r*keepc #LKtttt||d}||z }t ||}t j|\}}ttt||}t||D]\}} | |kr|VdS)zIList candidates for numbered directories to be removed - follows py.path.rzrN) rrr~rxrq itertoolsteervzip) rirjrr max_deletepathspaths2numbersr+numbers r(cleanup_candidatesrYss9mD&&A&ABBBOOOL$J $ ' 'EM%((ME6)-ff==>>GE7++ f Z  JJJr*c|D]P}|r:|s|QdSr8)rmrrYexistsrJ)rileft_dirs r(cleanup_dead_symlinksreshLLNN""     "##%%,,.. "!!!""r*c|sdSt|||D]}t|||dD]}t||t |dS)z-Cleanup for lock driven numbered directories.Nz garbage-*)rrrglobr)rirjrrr+s r(cleanup_numbered_dirrls ;;=="466@@D>???? +&&@@D>????$r* lock_timeoutcLd}tdD]} t|||}|dkrt|}t||j|z } t jt|||| |cS#t$r } | }Yd} ~ d} ~ wwxYw|J|)z>Create a numbered dir with a cleanup lock and remove old ones.Nrr) rrrrr:ratexitrrr) rirjrrr?rrr6rrrQs r(make_numbered_dir_with_cleanuprzs A 2YY !$55Aqyy/22 -i8884566883D|3S 0 O$4    HHH   AAAAAA  === Gs5B BBBinputrootpathct|}t|}t|rt|S||Sr8)r r r r r.)rrs r(resolve_from_strrsJ u  E u  E U||(E{{  '''r*patternzos.PathLike[str]ct|}tjd}|r2t|vr)t |vr |t t}t|vr|j}nSt|}| r0tj |sdtj|}tj ||S)aA port of FNMatcher from py.path.common which works with PurePath() instances. The difference between this algorithm and PurePath.match() is that the latter matches "**" glob expressions for each part of the path, while this algorithm uses the whole path instead. For example: "tests/foo/bar/doc/test_foo.py" matches pattern "tests/**/doc/test*.py" with this algorithm, but not with PurePath.match(). This algorithm was ported to keep backward-compatibility with existing settings which assume paths match according this logic. References: * https://bugs.python.org/issue29249 * https://bugs.python.org/issue34731 win*)rrVrWrXr posix_sepreplacernrM is_absoluter9r+r fnmatch)rr+iswin32rns r( fnmatch_exrs$ D>>Dl%%e,,G23g%%)w*>*>//)S11 'y4yy      ,bgmmG&<&< ,+"&+'++G ?4 ) ))r*sc|tfdttDS)Nc\h|](}tjd|dzpt)S)Nr4)r join).0rpartss r( zparts..s4 G G GCHU7QU7^ $ $ + G G Gr*)splitr rrt)rrs @r(rrs: GGCLLE G G G GU3u::5F5F G G GGr*c tjt|t|fi|dS#t$r}t d|Yd}~dSd}~wwxYw)zDMake a symlink, or skip the test in case symlinks are not supported.zsymlinks not supported: N)r9symlinkrMrr)srcdstkwargsrs r(symlink_or_skiprs{- 3s88SXX0000000 --- + + +,,,,,,,,,-s-1 AAAceZdZdZdZdZdZdS) ImportModez6Possible values for `mode` parameter of `import_path`.prependappend importlibN)__name__ __module__ __qualname____doc__rrrr*r(rrs#@@G FIIIr*rceZdZdZdS)ImportPathMismatchErroraRaised on import_path() if there is a mismatch of __file__'s. This can happen when `import_path` is called multiple times with different filenames that has the same basename but reside in packages (for example "/tests1/test_foo.py" and "/tests2/test_foo.py"). N)rrrrrr*r(rrsr*rrczt|}t|}|st||tjurt ||}t jD]/}||t|j g}|n.0tj |t|}|td|d|tj |}|t j|<|j|t#t j||St%|}|w|j } t'|d| j} | ddkr| d| }n|j } |j}|tjurHt| t jvr,t jt| nn|tjurQt| t jdkr-t jdt| nt=|t j|t j|}|j d kr|StBj"#d d} | d kr|j$} | tK|| || &d r | dd} | &tBj'd zr%| dtQtBj'd z } tSt|| } n#tT$rd } YnwxYw| stK|| ||S)aImport and return a module from the given path, which can be a file (a module) or a directory (a package). The import mechanism used is controlled by the `mode` parameter: * `mode == ImportMode.prepend`: the directory containing the module (or package, taking `__init__.py` files into account) will be put at the *start* of `sys.path` before being imported with `importlib.import_module`. * `mode == ImportMode.append`: same as `prepend`, but the directory will be appended to the end of `sys.path`, if not already in `sys.path`. * `mode == ImportMode.importlib`: uses more fine control mechanisms provided by `importlib` to import the module, which avoids having to muck with `sys.path` at all. It effectively allows having same-named test modules in different places. :param root: Used as an anchor when mode == ImportMode.importlib to obtain a unique name for the module being imported so it can safely be stored into ``sys.modules``. :raises ImportPathMismatchError: If after importing the given `path` and the module `__file__` are different. Only raised in `prepend` and `append` modes. NzCan't find module z at location rz__init__.r __init__.pyPY_IGNORE_IMPORTMISMATCH1)z.pycz.pyoF)+rr r ImportErrorrmodule_name_from_pathrV meta_path find_specrMrRutilspec_from_file_locationmodule_from_specmodulesloader exec_moduleinsert_missing_modulesresolve_package_pathlist with_suffix relative_torpoprstemrr+rinsertr import_modulernr9environget__file__rendswithr rt_is_samerC)r6r?rir+ module_name meta_importerspecmodpkg_pathpkg_rootnamesignore module_fileis_sames r( import_pathr%sp> d  D 77D ;;== $ z###+D$77  ] R RM **;T[9I9I8JKKD >99+s4yyQQD <S;SSTSSTT Tn--d33#& K  $$$s{K888 #D))H?T%%b))55h??EFF 9 " " IIKKKhhuoo ;i  z   x== ( ( HOOCMM * * * # # # x==CHQK ' ' HOOAs8}} - - -T K((( +k "C yM!! Z^^6 ; ;F }}l  )+{DII I    0 1 1 +%crc*K    6 7 7 H%&F#bf}.D*E*E(F&FGK s4yy+66GG    GGG  J)+{DII I Js8N N%$N%rf1f2ct|t|kptj||Sr8)r r9r+samefiler&r's r(rrUs0Bxx488#?rw'7'7B'?'??r*cBtj||Sr8)r9r+r)r*s r(rrZswB'''r*c|d} ||}|j}n#t$r|jdd}YnwxYwd|S)z Return a dotted module name based on the given path, anchored on root. For example: path="projects/src/tests/test_foo.py" and root="/projects", the resulting module name will be "src.tests.test_foo". rr4Nr)rrrr|r)r+ri relative_path path_partss r(rr^s   B  D)((.. #( $$$Z^ $ 88J  s4AAr rc6|d}|r||vrO tjstt j|n&#t$rt |d}|||<YnwxYw|dd|}|dSdS)aM Used by ``import_path`` to create intermediate modules when using mode=importlib. When we want to import a module as "src.tests.test_foo" for example, we need to create empty modules "src" and "src.tests" after inserting "src.tests.test_foo", otherwise "src.tests.test_foo" is not importable by ``__import__``. rz6Empty module created by pytest's importmode=importlib.)docrzN) rrVrModuleNotFoundErrorrrrrr)r r module_partsmodules r(r r ss$$S))L - g % % . }.--' 4444& . . .#P(. $$$  . hh|,, # -----s'A A('A(cd}tj|f|jD]\}|rF|dsn|jsn|}]|S)zReturn the Python package path by looking for the last directory upwards which still contains an __init__.py. Returns None if it can not be determined. Nr)rchainrOis_dirr.rNrn isidentifier)r+resultrRs r(rrs F/4'4<88 ==?? ??=1199;; ;++-- F Mr*zos.DirEntry[str]c@g}tj|5}|D]T} |n'#t$r}t |rYd}~6d}~wwxYw||U dddn #1swxYwY|d|S)z`Scan a directory recursively, in breadth-first order. The returned entries are sorted. Nc|jSr8)rnentrys r(zscandir..s5:r*)key)r9scandirrNrr)rsort)r+entriesrr<errs r(r?r?s G D   "Q " "E      %%HHHH  NN5 ! ! ! ! " " " " " " " " " " " " " " " " LL--L... Ns<A<2A< AA A<AAA<<BBrecursec#Kt|}|Ed{V|D]<}|r&||rt|j|Ed{V=dS)zWalk a directory recursively, in breadth-first order. The `recurse` predicate determines whether a directory is recursed. Entries at each directory level are sorted. N)r?r6visitr+)r+rCrAr<s r(rErEsdmmG22 <<>> 2ggenn 2UZ11 1 1 1 1 1 1 122r*ctttjt |S)zConvert a path to an absolute path using os.path.abspath. Prefer this over Path.resolve() (see #6523). Prefer this over Path.absolute() (not public, doesn't normalize). )r r9r+abspathrMr/s r( absolutepathrHs& D ** + ++r*path1path2c ttjt |t |fS#t $rYdSwxYw)zReturn the common part shared with the other path, or None if there is no common part. If one path is relative and one is absolute, returns None. N)r r9r+ commonpathrMr|)rIrJs r(rLrLsX BG&&E CJJ'?@@AAA ttsAA AA directorydestct|tsJt|tsJ||kr tjSt ||}|st |S||}||}tjjgtj gt|j z|j RS)zReturn a string which is a relative path from directory to dest such that directory/bestrelpath == dest. The paths must be either both absolute or both relative. If no such path can be determined, returns dest. ) rAr r9curdirrLrMrr+rpardirrtr)rMrNbase reldirectoryreldests r( bestrelpathrUs i & &&& & dD ! !!! ! yy i & &D 4yy((..Lt$$G 7<  9+L.// /      r*sourcec|sJt|dD]}t|}||}||z }|jd|r(|tj || rtj |||r|ddS)z.Recursively copy a source directory to target.c,| Sr8)rr;s r(r=zcopytree..s9I9I9K9K5Kr*)rCT)exist_okN) r6rEr rrRrrrr9readlinkrNrfcopyfile)rVrr<rprelpathnewxs r(copytreer^s ==???v'K'KLLL & & KK--'' 4((( <<>> & OOBKNN + + + + YY[[ & OAt $ $ $ $ XXZZ & JJJ % % % & &r*)r)grrrimportlib.utilrrr9rfrVtypesrrEenumrr"rrrr functoolsros.pathr r r r pathlibr r posixpathrrtypingrrrrrrrrrrr_pytest.compatr_pytest.outcomesr_pytest.warning_typesr LOCK_TIMEOUTrr%r&r)r0rMrB TracebackTypeboolrSr[rZrhrqrvrxr{r~rrrrrrfloatrrrrrrrrrrrrrrr%rWrXrrr rr?rErHrLrUr^rr*r(rns   &&&&&&''''''!!!!!!////// w~X666 7E51 " """""< < d=!=(5;N2OOP R<< <<<<~dt$ #s #s # # # #222222chtn8H-sx}AAcAhsmAAAA C  c8m, 7 &T &4 &D & & & & & &r*