a  zeJ@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z ddl mZmZmZmZddlmZddlmZGd d d e ZGd d d e ZGd ddejejejejZGdddejejejZddZedkreedS)zTests for distutils.dist.N)mock) Distributionfix_help_options)Command)TESTFNcaptured_stdoutcaptured_stderr run_unittest)support)logc@seZdZdZdgZddZdS) test_distz#Sample distutils extension command.)zsample-option=Sz help textcCs d|_dSN) sample_optionselfrM/opt/bitninja-python-dojo/embedded/lib/python3.9/distutils/tests/test_dist.pyinitialize_optionssztest_dist.initialize_optionsN)__name__ __module__ __qualname____doc__Z user_optionsrrrrrr sr c@seZdZdZddZdS)TestDistributionzDistribution subclasses that avoids the default search for configuration files. The ._config_files attribute must be set before .parse_config_files() is called. cCs|jSr) _config_filesrrrrfind_config_files(sz"TestDistribution.find_config_filesN)rrrrrrrrrr srcszeZdZfddZfddZdddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZZS)DistributionTestCasecs4tt|tjtjddf|_tjdd=dS)N)superrsetUpsysargvr __class__rrr1szDistributionTestCase.setUpcs2|jdt_|jdtjdd<tt|dSNrr)r!r rrtearDownrr"rrr%6s zDistributionTestCase.tearDownrcCs t}||_|||Sr)rrZparse_config_filesparse_command_line)rZ configfilesdrrrcreate_distribution;s z(DistributionTestCase.create_distributioncCs*tjd|}||dgdS)Nbuilddistutils.command)r r!appendr( assertEqualget_command_packages)rr'rrr!test_command_packages_unspecifiedBs z6DistributionTestCase.test_command_packages_unspecifiedcCs`ddlm}tjgd|}||gd|d}| ||||j ddS)Nr)r )--command-packageszfoo.bar,distutils.testsr z -Ssometext)r*foo.barzdistutils.testsr Zsometext) Zdistutils.tests.test_distr r r!extendr(r,r-Zget_command_objassertIsInstancer)rr r'cmdrrrtest_command_packages_cmdlineGs    z2DistributionTestCase.test_command_packages_cmdlinec Csxtjd|tjtd}ttd"}td ||dWdn1sP0Yt j j tddd}| tg}Wdn1s0Yt|f}|||||||||||||d }|t|jdt||jdD]\}}||||qt j j tdd d}| tg}Wdn1sD0Y|D]}|||jdiqVdS) Ninstallz/somedirwz[install] install-base = {0} install-platbase = {0} install-lib = {0} install-platlib = {0} install-purelib = {0} install-headers = {0} install-scripts = {0} install-data = {0} prefix = {0} exec-prefix = {0} home = {0} user = {0} root = {0}filez/a)prefix base_prefix) Z install_baseZinstall_platbaseZ install_libZinstall_platlibZinstall_purelibZinstall_headersZinstall_scriptsZ install_datar9 exec_prefixhomeuserrootz/b)r r!r+ addCleanuposunlinkropenprintformatrZpatchZmultipler(r,sortedZcommand_optionsgetkeysitems assertNotIn) rZfakepathfvaluesr' option_tupleZ result_dictkeyvaluerrrtest_venv_install_optionsVsH    $* , z.DistributionTestCase.test_venv_install_optionscCstjd|tjtttd}z$td|dtd|dW| n | 0| tg}| | gdgdtjdd<| tg}| | d d ggd tjdd<| tg}| | d gdS) Nr)r6z[global]r7z!command_packages = foo.bar, splat)r*r0Zsplat)r/sporkr)rr*rP)r/r)) r r!r+r?r@rArrBrCcloser(r,r-)rrJr'rrr test_command_packages_configfiles&        z5DistributionTestCase.test_command_packages_configfilecsbgfdd}|ttdtj|t_tddddidd}|td|d t|dS) Ncs|dSr)r+)msgZwarnsrr_warnsz6DistributionTestCase.test_empty_options.._warnwarnxxxZxxxx)Zauthornameversionurloptionsattrsrr\) r?setattrwarningsrWrr,lenrIdir)rrVdistrrUrtest_empty_optionss  z'DistributionTestCase.test_empty_optionscCsddd}t|d}|||jjddg||jjddgddd}t|d}|||jjdg||jjdgdS)None,two)keywords platformsr]onetwozfoo bar)rZfinalize_optionsr,metadatargrfrr^rcrrrtest_finalize_optionss  z*DistributionTestCase.test_finalize_optionscCs\t}||jd|}||dg||jdgd|_|}||gddS)Nr*re)r*rhri)rr,Zcommand_packagesr-)rrcZcmdsrrrtest_get_command_packagessz.DistributionTestCase.test_get_command_packagescCs(t}d}ddi}|t|j||dS)N)oklevelZok2)r assertRaises ValueErrorZannounce)rrcargskwargsrrr test_announcesz"DistributionTestCase.test_announcecs|tjdkr"tjd}ntjd}t|d}|dWdn1sZ0Yfdd}tjj}|tj_z2t}| }tdd gid }| }W|tj_n |tj_0| t |d t |dS) Nposix.pydistutils.cfgpydistutils.cfgr6z [distutils] csSrr)pathZ temp_homerr _expanderszFDistributionTestCase.test_find_config_files_disable.._expanderZ script_argsz --no-user-cfgr]r) mkdtempr@rYrxjoinrBwrite expanduserrrr,ra)r user_filenamerJrzZ old_expanderr'Z all_filesfilesrryrtest_find_config_files_disables   (  z3DistributionTestCase.test_find_config_files_disable)r)rrrrr%r(r.r4rOrSrdrlrmrtr __classcell__rrr"rr,s   : rcseZdZfddZfddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0ZZS)1MetadataTestCasecs(tt|tjtjddf|_dSr)rrrr r!rr"rrrszMetadataTestCase.setUpcs2|jdt_|jdtjdd<tt|dSr$)r!r rrr%rr"rrr%s zMetadataTestCase.tearDowncCst}|j||Sr)ioStringIOrjwrite_pkg_filegetvalue)rrcsiorrrformat_metadata s z MetadataTestCase.format_metadatacCs\ddd}t|}||}|d||d||d||d|dS)Npackage1.0)rYrZzMetadata-Version: 1.0 provides: requires: obsoletes:)rrassertInrIlowerrr^rcmetarrrtest_simple_metadatas  z%MetadataTestCase.test_simple_metadatacCs|ddddgd}t|}||jddg||ddg||}|d||d||d|dS)Nrrz package.subrYrZZprovidesMetadata-Version: 1.1rr)rr,rjZ get_providesrrrIrrrrr test_providess    zMetadataTestCase.test_providescCs|ttdddgddS)Nrrmy.pkg (splat)rrprqrrrrrtest_provides_illegal(s z&MetadataTestCase.test_provides_illegalcCsddddgd}t|}||jddg||ddg||}|d||d||d||d ||d |dS) Nrrotherzanother (==1.0)rYrZrequiresrrzRequires: otherzRequires: another (==1.0)r)rr,rjZ get_requiresrrrIrrrrr test_requires.s"      zMetadataTestCase.test_requirescCs|ttdddgddS)Nrrrrrrrrrtest_requires_illegal>s z&MetadataTestCase.test_requires_illegalcCs,dtdgd}t|}||jjtdS)Nrr)rYr)iterrr2rjrlistrkrrrtest_requires_to_listDs z&MetadataTestCase.test_requires_to_listcCsddddgd}t|}||jddg||ddg||}|d||d||d||d ||d |dS) Nrrrzanother (<1.0)rYrZ obsoletesrrrzObsoletes: otherzObsoletes: another (<1.0))rr,rjZ get_obsoletesrrrIrrrrrtest_obsoletesKs"     zMetadataTestCase.test_obsoletescCs|ttdddgddS)Nrrrrrrrrrtest_obsoletes_illegal[s z'MetadataTestCase.test_obsoletes_illegalcCs,dtdgd}t|}||jjtdS)Nrr)rYr)rrr2rjrrrkrrrtest_obsoletes_to_listas z'MetadataTestCase.test_obsoletes_to_listcCsBdddgd}t|}||dg||}|d|dS)NBoa3.0#Programming Language :: Python :: 3rYrZ classifiersr)rr,Zget_classifiersrrrrrrtest_classifiergs  z MetadataTestCase.test_classifiercCsvdddd}t}t|}Wdn1s00Y|d|||jjt||jjt|ddS)Nrr)rrshould be a listr) rrrrr2rjrrr,rr^errorr'rrrtest_classifier_invalid_typeps&  z-MetadataTestCase.test_classifier_invalid_typecCs0ddgdd}t|}||gddS)NMontyrZspamZeggsz life of brianrYrZrf)rr,Z get_keywordsrkrrr test_keywords|s zMetadataTestCase.test_keywordscCsvdddd}t}t|}Wdn1s00Y|d|||jjt||jjt|ddS)Nrrrrrrf) rrrrr2rjrfrr,rrrrtest_keywords_invalid_types&z+MetadataTestCase.test_keywords_invalid_typecCs0ddddgd}t|}||ddgdS)Nrr GNU/LinuxSome Evil PlatformrYrZrg)rr,Z get_platformsrkrrrtest_platformss zMetadataTestCase.test_platformscCsvdddd}t}t|}Wdn1s00Y|d|||jjt||jjt|ddS)Nrr)rrrrrg) rrrrr2rjrgrr,rrrrtest_platforms_invalid_typess&z-MetadataTestCase.test_platforms_invalid_typescCs.dddd}t|}||}|d|dS)Nrrzhttp://example.org/boa)rYrZ download_urlr)rrrrrrrtest_download_urls  z"MetadataTestCase.test_download_urlcCsDtd}dd|d}t|}||}|dd}|||dS)Nzc example:: We start here and continue here and end here.rr)rYrZlong_descriptionz  )textwrapdedentrrreplacer)rZ long_descr^rcrrrrtest_long_descriptions   z&MetadataTestCase.test_long_descriptionc Cstjdkrd}nd}|}tj||}t|d}z|dW|n |0znt}t j dvr|tj d<| }| ||t j dkr|tj d <| }| ||d ||fWt|n t|0dS) Nrurvrwr6.)linuxdarwinHOMEwin32 USERPROFILEz%r not found in %r)r@rYr{rxr|rBr}rRrr platformenvironrrremove)rrZtemp_dirrJrcrrrrtest_custom_pydistutilss,         z(MetadataTestCase.test_custom_pydistutilscCs4ddg}t|}||dd||dddS)N)abcr')rr)rrrr)rrr)rr,)rZ help_tuplesZ fancy_optionsrrrtest_fix_help_optionssz&MetadataTestCase.test_fix_help_optionscCs~|tjtjjt}gt_d|_d|_ t }| Wdn1sN0Ydd| dD}||dS)Nrzsetup.pycSsg|]}|dkr|qS)rQ)strip).0linerrr s z3MetadataTestCase.test_show_help..r)r?r Z set_thresholdZ _global_logZ thresholdrr r!helpZ script_namerr&rsplitZ assertTrue)rrcsoutputrrrtest_show_helps&zMetadataTestCase.test_show_helpcCsdddddddgdgd }t|}|j}t}|||d ||||jd||j d||j d||j d||j ddg||j d g||jd||jdgdS) NrrZdescrXzhttp://example.comrhriZfoo)rYrZr descriptionrrfrrZUNKNOWN)rrjrrrseekZ read_pkg_filer,rYrZrrrfrgrr)rr^rcrjZPKG_INFOrrrtest_read_metadatas,   z#MetadataTestCase.test_read_metadata)rrrrr%rrrrrrrrrrrrrrrrrrrrrrrrrr"rrs0       #rcCs,t}|tt|tt|Sr)unittestZ TestSuiteZaddTestZ makeSuiterr)Zsuiterrr test_suite sr__main__) rr@rr rr`rrZdistutils.distrrZ distutils.cmdrZ test.supportrrrr Zdistutils.testsr Z distutilsr r rZLoggingSilencerZTempdirManagerZ EnvironGuardZTestCaserrrrrrrrs8      T