`I/ddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlZddlZddlmZmZmZddlZddlZGddeZGddZGd d Zd Zd Zd Zejdddefddefgeje j dddkoe j j!dkddZ"eje j dddkoe j j!dkddZ#ejdddgdZ$dZ%Gdd Z&Gd!d"Z'dS)#) annotationsN)mock)DistInfoDistribution DistributionEggInfoDistributionceZdZdZdS) EggRemoverc|tjvrtj|tj|rtj|dSdSN)syspathremoveosexists)selfs x/builddir/build/BUILD/cloudlinux-venv-1.0.10/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_classDs*  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_listdirIsg  &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#utf-8encodingz 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_changeas  /11  &s + +++GZ@@"001B1B1KLL&&&& 3 1 1 1      ] $ $ & & B8$$$++GZ@@ (W - - - /6688..... / / / / / / / / / / / / / / /!!#####sD??EEN) rrrr__annotations__rRr. classmethodr:r=rKr`rrrrr s#%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: )rBrPget_cache_pathstrtype isinstance)rmgrr type_messages rtest_get_cache_pathz'TestResourceManager.test_get_cache_path{sb+--!!%((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 rrvzCTestResourceManager.test_get_cache_path_race..patched_isdirsF  " ) )' 2 2 2%og..G % G$$$Nr)rfbarbazisdir)newrrfrw)rBryrqrPset_extraction_pathrhrsepr5rpatchobjectrglensplit)rtmpdirrk archive_namecalled_dirnamesrvs @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)rrrrnrrrrrrdrdzsI...@@@8 # # # # #rrdc0tj|}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 rsmkdirrVrWlistrBdistributions_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}||vs Jd|| |s Jd|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: zactual: ) rr r5rhencoderpytestraisesUnicodeDecodeError get_metadatavalueendswith) rr-rrrexcinfoexcr]expecteds rtest_get_metadata__bad_utf8rs1HGLLVoxHHM}}\**H !-( C C CD ) * *$g (###$$$$$$$$$$$$$$$ -C XXF ? v   2&22    ??= ) )>>+>f+>+>>> )>>s0BBBc||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-inforr{)rfinalz/https://github.com/python/cpython/issues/103632reasoncd|}t||\}}d|d}tj||}t jt 5} |jdddn #1swxYwYt| j } || vsJt|| f| j j \} }|| vsJ|| vsJt|| ft||usJdS)zI Test Distribution.version when the "Version" header is missing. zfoo.z!Missing 'Version:' header and/or z file at path: N) rrr r5rr ValueErrorversionrhrargsri) rr!rrrrr expected_textrrerrmsgs r!test_distribution_version_missingrsZ"fH1&(CCND( O,=NNNGLL+<==M z " "g  gm  C C   mS%9!:!:    "IC C     C   mS%9!:!:    ::+ + + + + + +sA,,A03A0ctd}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_factoryrh)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_openEs(yL0B4BBB6BBBrz builtins.open) side_effect114) builtinsrVsetattrrMockplistlibdumprrB _macos_vers cache_clear assert_called) monkeypatchr fake_filermrs ` @rtest_macos_vers_fallbackr7s 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 EnvironmentrYs Drr)homelibscriptsdatazegg-basec3@K|]}|t|z fVdSr )rh).0rsrs r z5TestDeepVersionLookupDistutils.env.._s5NNg'3v'7#8#89NNNNNNr) rhchmodrTS_IRWXUdictpathsrmaprrvalues)rrrenvsubss ` rrz"TestDeepVersionLookupDistutils.envRs     #   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! ❄rf)r4rlong_descriptionrN) r distutilsrrcommandinstall_egg_infoinitialize_optionsr install_dirfinalize_optionsrun)rrrldattrsriei_cmds rcreate_foo_pkgz-TestDeepVersionLookupDistutils.create_foo_pkgcs 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_infoqsv' C)))'--j99'5)9(:;;@@EE|w&&&&&&r) unnormalized normalized))rfrf)zfoo/rf)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_sep{s>$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.Nr r 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 parametrizerskipifrr normcaserrrrrrrrQs ^^   ''' [&   BBB [ !1!1#!6!666 [& (  BB  B  [  tF [$   )) )))rrcneZdZdZdddddZejdgdd Zd S) TestWorkdirRequirech|dz }||jD]O\}}||z }|jdd|t j|dP|td|gtj |S)Nz site-packagesT)exist_okparentsrMrNr ) rFILESitemsparent write_textinspectcleandocrr rfspath)rrr dist_files site_packagesrcontentr s rfake_site_packagesz%TestWorkdirRequire.fake_site_packagess ?2 !Z--// I IMD' 4'D K  tT  : : : OOG,W55O H H H HC-999y'''rze Metadata-Version: 2.4 Name: pkg1.mod Version: 1.2.3 zd Metadata-Version: 2.1 Name: pkg2.mod Version: 0.42 zE Name: pkg3.mod Version: 1.2.3.4 zD Name: pkg4.mod Version: 0.42.1 )z!pkg1_mod-1.2.3.dist-info/METADATAz pkg2.mod-0.42.dist-info/METADATAzpkg3_mod.egg-info/PKG-INFOzpkg4.mod.egg-info/PKG-INFO)r requirement))z1.2.3z pkg1.mod>=1)z0.42z pkg2.mod>=0.4)z1.2.3.4z pkg3.mod<=2)z0.42.1zpkg4.mod>0.2,<1cr||||j}tj|g}||ddfD]l}||\}|j|ksJtj tj |j |g|sJmdS)N.-) r,r"rBrreplacerequirerrr samefile commonpathlocation) rrrrr-r*wsrrs r test_require_non_normalised_namez3TestWorkdirRequire.test_require_non_normalised_names//+tzRR  %}o 6 6!4!4S#!>!>?  CZZ__FT<7****7##""DM=#ABBM     rN) rrrr,r"rrrr7rrrrrs ( ( (. - ''  E* ["        rr)( __future__rrrRr&rrrTrr r(r*unittestrrrBrrr"distutils.command.install_egg_infordistutils.distrhr rrdrrrrrxfail version_info releaselevelrrrrrrrrrr?s """"""    QQQQQQQQQQ))))W$W$W$W$W$W$W$W$t3#3#3#3#3#3#3#3#l(???4"9 Z!45 j"67RaRG#P(8(E(P <,, ,>RaRG#P(8(E(P < $%//OO0/O4[)[)[)[)[)[)[)[)|6666666666r