\bg;ddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl Z ddlZddlmZmZmZddlZddlZGddeZGddZGd d Zd Zd Zd Ze jdddefddefge jejdddkoejj dkddZ!e jejdddkoejj dkddZ"e jdddgdZ#dZ$Gdd Z%dS)!) annotationsN)mock)DistInfoDistribution DistributionEggInfoDistributionceZdZdZdS) EggRemoverc|tjvrtj|tj|rtj|dSdSN)syspathremoveosexists)selfs w/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pkg_resources/tests/test_pkg_resources.py__call__zEggRemover.__call__sT 38   HOOD ! ! ! 7>>$    IdOOOOO  N)__name__ __module__ __qualname__rrrr r s#rr ceZdZUgZded<ejddddddZ ed Zed Z d Z d Z d S)TestZipProviderzlist[EggRemover] finalizersi rctjdd}tj|d}tj}d|_|j|_| |dtj}d|_|j|_| |dtj}d |_|j|_| |d tj}d |_|j|_| |d | | tj |jtj |jd }tj ||j t%||j t%|jdS)z'create a zip egg and add it to sys.pathz.eggF)suffixdeletewmod.pyzx = 3 data.dat hello, world!zsubdir/mod2.pyzx = 6 zsubdir/data2.datzgoodbye, world!subdirN)tempfileNamedTemporaryFilezipfileZipFileZipInfofilenameref_time timetuple date_timewritestrcloser r appendnamerjoinrr )clseggzip_eggzip_infor's r setup_classzTestZipProvider.setup_class%s)FFF/#s++?$$$ \33559---?$$& \3355?333?$$, \33559---?$$. \3355#4555   !!!ch11  j00111 j2233333rc.|jD] }| dSr )r)r6 finalizers rteardown_classzTestZipProvider.teardown_classCs*  I IKKKK  rcddl}tj|}gd}t|d|ksJddg}t|d|ksJt|d|ksJ|dgksJ|d gksJddl}tj|}t|d|ksJ|dgksJ|dgksJdS) Nr)r%r$r'z data2.datzmod2.pyr'zsubdir/ nonexistentz nonexistent/)mod pkg_resources ZipProvidersortedresource_listdirmod2)rrAzp expected_rootexpected_subdirrFzp2s rtest_resource_listdirz%TestZipProvider.test_resource_listdirHsg  &s + +888 b))"--..-????& 2b))(3344GGGGb)))4455HHHH""=11R7777"">22b8888 '--c**2..//?BBBB##H--3333##I.."444444rcddl}tj}tj|}||d}t jtj|j }||j ksJt|dd}| d| |j }tj|||f||d}t|d5}|dksJ dddn #1swxYwY|dS) a If a previous call to get_resource_filename has saved the file, but the file has been subsequently mutated with different file of the same size and modification time, it should not be overwritten on a subsequent call to get_resource_filename. rNr%r#zutf-8)encodingz hello, world?r&)rArBResourceManagerrCget_resource_filenamedatetime fromtimestamprstatst_mtimer.openwriter2 timestamputimereadcleanup_resources)rrAmanagerrGr-actualftss r)test_resource_filename_rewrites_on_changez9TestZipProvider.test_resource_filename_rewrites_on_change`s  /11  &s + +++GZ@@"001B1B1KLL&&&& 3 1 1 1      ] $ $ & & B8$$$++GZ@@ (W - - - /6688..... / / / / / / / / / / / / / / /!!#####sD??EEN) rrrr__annotations__rPr. classmethodr:r=rKr^rrrrrs#%J%%%% x q"b"a88H.44[4:[5550$$$$$rrc"eZdZdZdZ dZdS)TestResourceManagerctj}|d}tt |}d|z}t |ts J|dS)Nfooz%Unexpected type from get_cache_path: )rBrNget_cache_pathstrtype isinstance)rmgrr type_messages rtest_get_cache_pathz'TestResourceManager.test_get_cache_pathzsb+--!!%((DJJ9EA$$$--g--$--rctjffd g_tj}|t |t jd}tj td5| |dddn #1swxYwYj}t|dksJ|dt jdddd gksJ|d t jd ddgksJdS) Nc~j|||}|stj||Sr )dirnamesr3rmakedirs)dirnameunpatched_isdirwas_dir patched_isdirs rrtzCTestResourceManager.test_get_cache_path_race..patched_isdirsF  " ) )' 2 2 2%og..G % G$$$Nr)rdbarbazisdir)newrrdru)rBrwrorNset_extraction_pathrfrsepr5rpatchobjectrelensplit)rtmpdirri archive_namecalled_dirnamesrts @rtest_get_cache_path_racez,TestResourceManager.test_get_cache_path_races3@3F      "$ +-- F ,,,v{{#899 Z  }g=  I I - -   | , , , - - - - - - - - - - - - - - - (0?##q((((q!''//4FFFFq!''//4??????sB77B;>B;cvd}tjdd|g}tj|dS)z In a separate Python environment, import pkg_resources and assert that action doesn't cause setuptools to be imported. )zimport pkg_resourcesz import syszAassert "setuptools" not in sys.modules, "setuptools was imported"z-cz; N)r executabler5 subprocess check_call)rlinescmds rtest_setuptools_not_importedz0TestResourceManager.test_setuptools_not_importeds<   ~tTYYu%5%56c"""""rN)rrrrlrrrrrrbrbysI...@@@8 # # # # #rrbc0tj|}tj|t |d5}||dddn #1swxYwYt tj|}|\}|S)a Make a test Distribution object, and return it. :param metadata_path: the path to the metadata file that should be created. This should be inside a distribution directory that should also be created. For example, an argument value might end with ".dist-info/METADATA". :param metadata: the desired contents of the metadata file, as bytes. wbN) rr rqmkdirrTrUlistrBdistributions_from_metadata) metadata_pathmetadatadist_dirr\distsdists rmake_test_distributionrsw}--HHX mT " "a  :8DD E EEGT KsA&&A*-A*cd}tjt|d|}dd}t ||}t jt5}| |dddn #1swxYwY|j }t|}d}||vsJd || |sJd |dS) zI Test a metadata file with bytes that can't be decoded as utf-8. METADATAz foo.dist-infounéez iso-8859-1)rNz`codec can't decode byte 0xe9 in position 1: invalid continuation byte in METADATA file at path: z actual: {}) rr r5rfencoderpytestraisesUnicodeDecodeError get_metadatavalueformatendswith) rr-rrrexcinfoexcr[expecteds rtest_get_metadata__bad_utf8rs;HGLLVoxHHM}}\**H !-( C C CD ) * *$g (###$$$$$$$$$$$$$$$ -C XXF ? v   |226::    ??= ) )FF<+>+>v+F+FFF )FFs0BBBc||z }||dtt j|}t |dksJ|\}||fS)zN Create a distribution directory with no file containing the version. ztemp.txtr{) ensure_dirr5ensurerrBrr)rbasenamerrrs rmake_distribution_no_versionrs| H  MM*$$&&& :8DD E EE u::????GT >r)r!expected_filenameexpected_dist_typezegg-infozPKG-INFOz dist-inforry)rfinalz/https://github.com/python/cpython/issues/103632reasoncd|}t||\}}d|}tj||}t jt5} |jdddn #1swxYwYt| j } || vsJt|| f| j j \} }|| vsJ|| vsJt|| ft||usJdS)zI Test Distribution.version when the "Version" header is missing. zfoo.{}z2Missing 'Version:' header and/or {} file at path: N) rrrr r5rr ValueErrorversionrfrargsrg) rr!rrrrr expected_textrrerrmsgs r!test_distribution_version_missingrsa"v&&H1&(CCND(IQQMGLL+<==M z " "g  gm  C C   mS%9!:!:    "IC C     C   mS%9!:!:    ::+ + + + + + +s7B  BBctd}tjt5}|jdddn #1swxYwY|jj\}}d}||ksJdS)zl Test Distribution.version when the "Version" header is missing and the path can't be detected. z/fooNzJMissing 'Version:' header and/or PKG-INFO file at path: [could not detect])rrrrrrr)rrrrs r1test_distribution_version_missing_undetected_pathrs   D z " "g  "ICT  (??????s=AAonlyFTc|dz }|tjt|t||rJdS)z5Test path containing a file with dist-info extension.zfoobar.dist-infoN)touchrB dist_factoryrf)tmp_pathr dist_infos rtest_dist_info_is_not_dirr.sL--I OO)#h--YNNNN NNNrctj|dtjdtdz d5}t jddi|dddn #1swxYwY|d tjd fd }tjd tj| 5}tj tj ddgksJtj dddn #1swxYwY| dS)z-Regression test for pkg_resources._macos_verszplatform.mac_ver)r?rr?) return_value fake.plistrProductVersionz11.4Nzos.path.existsTc"dz g|Ri|S)Nrr)filerkwargs orig_openrs r fake_openz+test_macos_vers_fallback..fake_openDs(yL0B4BBB6BBBrz builtins.open) side_effect114) builtinsrTsetattrrMockplistlibdumprrB _macos_vers cache_clear assert_called) monkeypatchr fake_filermrs ` @rtest_macos_vers_fallbackr6s I*DI<,P,P,PQQQ h%t , ,=  '0)<<<===============($)*F*F*FGGGCCCCCC OTY9%E%E%E F F0!!--///(**tSk9999!--///000000000000000 OOs% A//A36A3AD55D9<D9c(eZdZejdZdZdZej dgddZ ej e j de j dkd ej dd gd Zej e j jd kd ej dgddZdS)TestDeepVersionLookupDistutilscBGddt}|}tjd}t fd|D|_t ttj |j |S)zq Create a package environment, similar to a virtualenv, in which packages are installed. ceZdZdS)7TestDeepVersionLookupDistutils.env..EnvironmentN)rrrrrr EnvironmentrXs Drr)homelibscriptsdatazegg-basec3@K|]}|t|z fVdSr )rf).0rqrs r z5TestDeepVersionLookupDistutils.env..^s5NNg'3v'7#8#89NNNNNNr) rfchmodrRS_IRWXUdictpathsrmaprrvalues)rrrenvsubss ` rrz"TestDeepVersionLookupDistutils.envQs     #   k&!! T\""";NNNNNNNNN  S39++-- . ./// rcPd}td||}tj|}tjj|}||jd|_| | dS)zj Create a foo package installed (distutils-style) to env.paths['lib'] as version. u&This package has unicode metadata! ❄rd)r4rlong_descriptionrN) r distutilsrrcommandinstall_egg_infoinitialize_optionsr install_dirfinalize_optionsrun)rrrldattrsriei_cmds rcreate_foo_pkgz-TestDeepVersionLookupDistutils.create_foo_pkgbs 6%2FFF~**511#4EEdKK""$$$!i.  """ rcd}|||tjd}tj|jdg|}|j|ksJdS)Nz1.11.0.dev0+2329eaezfoo>=1.9r)rrB Requirementparse WorkingSetrfindr)rrrreqrs r#test_version_resolved_from_egg_infozBTestDeepVersionLookupDistutils.test_version_resolved_from_egg_infopsv' C)))'--j99'5)9(:;;@@EE|w&&&&&&r) unnormalized normalized))rdrd)zfoo/rd)foo/barr)zfoo/bar/rcftj|}tj|}||ksJdS)zeEnsure the trailing slash is cleaned for path comparison. See pypa/setuptools#1519. NrBnormalize_pathrrrresult_from_unnormalizedresult_from_normalizeds r test_normalize_path_trailing_sepz?TestDeepVersionLookupDistutils.test_normalize_path_trailing_sepzs>$1#? #M#M !.!=j!I!I'+AAAAAAArAaz%Testing case-insensitive filesystems.r)z MiXeD/CasEz mixed/casecftj|}tj|}||ksJdS)z@Ensure mixed case is normalized on case-insensitive filesystems.Nrr s rtest_normalize_path_normcasez;TestDeepVersionLookupDistutils.test_normalize_path_normcases>$1#? #M#M !.!=j!I!I'+AAAAAAAr\z5Testing systems using backslashes as path separators.)rr))z forward/slash forward\slash)zforward/slash/r)zbackward\slash\zbackward\slashc\tj|}||sJdS)z;Ensure path seps are cleaned on backslash path sep systems.N)rBr r)rrrresults r!test_normalize_path_backslash_sepz@TestDeepVersionLookupDistutils.test_normalize_path_backslash_seps2-l;;x(((((((rN)rrrrfixturerrrmark parametrizer skipifrr normcaserr~rrrrrrPs ^^   ''' [&   BBB [ !1!1#!6!666 [& (  BB  B  [  tF [$   )) )))rr)& __future__rrrPrrrRrr r(r*unittestrrrBrrr"distutils.command.install_egg_infordistutils.distrfr rrbrrrrrxfail version_info releaselevelrrrrrrrrr#s""""""    QQQQQQQQQQ))))W$W$W$W$W$W$W$W$t3#3#3#3#3#3#3#3#l(GGG4"9 Z!45 j"67RaRG#P(8(E(P <,, ,>RaRG#P(8(E(P < $%//OO0/O4[)[)[)[)[)[)[)[)[)[)r