HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/distutils/tests/__pycache__/test_dist.cpython-310.opt-2.pyc
o

�i�J�@s	ddlZddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZddlmZddlmZddlmZGd	d
�d
e�ZGdd�de�ZGd
d�dejejejej�ZGdd�dejejej�Zdd�Zedkr�ee��dSdS)�N)�mock)�Distribution�fix_help_options)�Command)�captured_stdout�captured_stderr�run_unittest)�TESTFN)�support)�logc@seZdZ	dgZdd�ZdS)�	test_dist)zsample-option=�Sz	help textcCs
d|_dS�N)�
sample_option��self�r�6/usr/local/lib/python3.10/distutils/tests/test_dist.py�initialize_optionss
ztest_dist.initialize_optionsN)�__name__�
__module__�__qualname__Zuser_optionsrrrrrrs
�rc@seZdZ	dd�ZdS)�TestDistributioncCs|jSr)�
_config_filesrrrr�find_config_files)sz"TestDistribution.find_config_filesN)rrrrrrrrr!srcszeZdZ�fdd�Z�fdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Z�ZS)�DistributionTestCasecs4tt|���tjtjdd�f|_tjdd�=dS)N�)�superr�setUp�sys�argvr��	__class__rrr2szDistributionTestCase.setUpc�2|jdt_|jdtjdd�<tt|���dS�Nrr)r rrr�tearDownrr!rrr%7�zDistributionTestCase.tearDownrcCs t�}||_|��|��|Sr)rrZparse_config_files�parse_command_line)rZconfigfiles�drrr�create_distribution<s
z(DistributionTestCase.create_distributioncCs*tj�d�|��}|�|��dg�dS)N�build�distutils.command)rr �appendr)�assertEqual�get_command_packages)rr(rrr�!test_command_packages_unspecifiedCsz6DistributionTestCase.test_command_packages_unspecifiedcCs`ddlm}tj�gd��|��}|�|��gd��|�d�}|�	||�|�|j
d�dS)Nr)r)�--command-packageszfoo.bar,distutils.testsrz
-Ssometext)r+�foo.barzdistutils.testsrZsometext)Zdistutils.tests.test_distrrr �extendr)r-r.Zget_command_obj�assertIsInstancer)rrr(�cmdrrr�test_command_packages_cmdlineHs
�
z2DistributionTestCase.test_command_packages_cmdlinec	Csttj�d�|�tjt�d}ttd��}td�	|�|d�Wd�n1s(wYt
jjtddd��}|�
tg�}Wd�n1sGwYt|f}|||||||||||||d�
}|�t|j�d����t|����|j�d���D]\}}|�|||�qzt
jjtdd	d��}|�
tg�}Wd�n1s�wY|��D]
}|�||j�di��q�dS)
N�installz/somedir�wz�[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_platbaseZinstall_libZinstall_platlibZinstall_purelibZinstall_headersZinstall_scriptsZinstall_datar:�exec_prefix�home�user�rootz/b)rr r,�
addCleanup�os�unlinkr	�open�print�formatrZpatchZmultipler)r-�sortedZcommand_options�get�keys�items�assertNotIn)	rZfakepath�f�valuesr(�option_tupleZresult_dict�key�valuerrr�test_venv_install_optionsWsL
����
���z.DistributionTestCase.test_venv_install_optionscCs�tj�d�|�tjt�ttd�}ztd|d�td|d�W|�	�n|�	�w|�
tg�}|�|��gd��gd�tjdd�<|�
tg�}|�|��d	d
g�gd�tjdd�<|�
tg�}|�|��d	g�dS)Nr*r7z[global]r8z!command_packages = foo.bar, splat)r+r1Zsplat)r0�sporkr*rr+rQ)r0�r*)
rr r,r@rArBr	rCrD�closer)r-r.)rrKr(rrr� test_command_packages_configfile�s&

�
�z5DistributionTestCase.test_command_packages_configfilecsbg��fdd�}|�ttdtj�|t_tddddid�d�}|�t��d�|�d	t|��dS)
Ncs��|�dSr)r,)�msg�Zwarnsrr�_warn�sz6DistributionTestCase.test_empty_options.<locals>._warn�warn�xxxZxxxx)Zauthor�name�version�url�options��attrsrr])	r@�setattr�warningsrXrr-�lenrJ�dir)rrW�distrrVr�test_empty_options�s
�z'DistributionTestCase.test_empty_optionscCs�ddd�}t|d�}|��|�|jjddg�|�|jjddg�ddd�}t|d�}|��|�|jjdg�|�|jjdg�dS)N�one,two)�keywords�	platformsr^�one�twozfoo bar)rZfinalize_optionsr-�metadatarhrg�rr_rdrrr�test_finalize_options�s�
�
z*DistributionTestCase.test_finalize_optionscCs\t�}|�|jd�|��}|�|dg�|�|jdg�d|_|��}|�|gd��dS)Nr+rf)r+rirj)rr-Zcommand_packagesr.)rrdZcmdsrrr�test_get_command_packages�s�z.DistributionTestCase.test_get_command_packagescCs(t�}d}ddi}|�t|j||�dS)N)�ok�levelZok2)r�assertRaises�
ValueErrorZannounce)rrd�args�kwargsrrr�
test_announce�sz"DistributionTestCase.test_announcecs�|���tjdkrtj��d�}ntj��d�}t|d��
}|�d�Wd�n1s-wY�fdd�}tjj}|tj_zt�}|�	�}tdd	gid
�}|�	�}W|tj_n|tj_w|�
t|�dt|��dS)N�posix�.pydistutils.cfg�pydistutils.cfgr7z[distutils]
cs�Srr)�path�Z	temp_homerr�	_expander�szFDistributionTestCase.test_find_config_files_disable.<locals>._expanderZscript_argsz
--no-user-cfgr^r)�mkdtemprArZry�joinrC�write�
expanduserrrr-rb)r�
user_filenamerKr{Zold_expanderr(Z	all_files�filesrrzr�test_find_config_files_disable�s"
�
z3DistributionTestCase.test_find_config_files_disable)r)rrrrr%r)r/r5rPrTrermrnrur��
__classcell__rrr!rr-s
:rcs�eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z�ZS)1�MetadataTestCasecs(tt|���tjtjdd�f|_dSr)rr�rrr rr!rrrszMetadataTestCase.setUpcr#r$)r rrr�r%rr!rrr%r&zMetadataTestCase.tearDowncCst��}|j�|�|��Sr)�io�StringIOrk�write_pkg_file�getvalue)rrd�siorrr�format_metadatasz MetadataTestCase.format_metadatacCs\ddd�}t|�}|�|�}|�d|�|�d|���|�d|���|�d|���dS)N�package�1.0)rZr[zMetadata-Version: 1.0�	provides:�	requires:�
obsoletes:)rr��assertInrJ�lower�rr_rd�metarrr�test_simple_metadatas�
z%MetadataTestCase.test_simple_metadatacCs|ddddgd�}t|�}|�|j��ddg�|�|��ddg�|�|�}|�d|�|�d|���|�d|���dS)Nr�r�zpackage.sub�rZr[Zprovides�Metadata-Version: 1.1r�r�)rr-rkZget_providesr�r�rJr�r�rrr�
test_providess��
�
zMetadataTestCase.test_providescC�|�ttdddgd��dS)Nr�r��my.pkg (splat)r��rqrrrrrrr�test_provides_illegal)���z&MetadataTestCase.test_provides_illegalcCs�ddddgd�}t|�}|�|j��ddg�|�|��ddg�|�|�}|�d|�|�d|���|�d|�|�d	|�|�d
|���dS)Nr�r��otherzanother (==1.0)�rZr[�requiresr�r�zRequires: otherzRequires: another (==1.0)r�)rr-rkZget_requiresr�r�rJr�r�rrr�
test_requires/s"��
�
zMetadataTestCase.test_requirescCr�)Nr�r�r�r�r�rrrr�test_requires_illegal?r�z&MetadataTestCase.test_requires_illegalcC�,dtdg�d�}t|�}|�|jjt�dS)Nr�r�)rZr�)�iterrr3rkr��listrlrrr�test_requires_to_listE�
�z&MetadataTestCase.test_requires_to_listcCs�ddddgd�}t|�}|�|j��ddg�|�|��ddg�|�|�}|�d|�|�d|���|�d|���|�d	|�|�d
|�dS)Nr�r�r�zanother (<1.0)�rZr[�	obsoletesr�r�r�zObsoletes: otherzObsoletes: another (<1.0))rr-rkZ
get_obsoletesr�r�rJr�r�rrr�test_obsoletesLs"��
�
zMetadataTestCase.test_obsoletescCr�)Nr�r�r�r�r�rrrr�test_obsoletes_illegal\r�z'MetadataTestCase.test_obsoletes_illegalcCr�)Nr�r�)rZr�)r�rr3rkr�r�rlrrr�test_obsoletes_to_listbr�z'MetadataTestCase.test_obsoletes_to_listcCsBdddgd�}t|�}|�|��dg�|�|�}|�d|�dS)N�Boa�3.0�#Programming Language :: Python :: 3�rZr[�classifiersr�)rr-Zget_classifiersr�r�r�rrr�test_classifierhs�
�
z MetadataTestCase.test_classifiercC�vdddd�}t��}t|�}Wd�n1swY|�d|���|�|jjt�|�|jjt|d��dS)Nr�r�)r�r��should be a listr�)	rrr�r�r3rkr�r�r-�rr_�errorr(rrr�test_classifier_invalid_typeqs�
�

�z-MetadataTestCase.test_classifier_invalid_typecCs0ddgd�d�}t|�}|�|��gd��dS)N�Montyr��ZspamZeggsz
life of brian�rZr[rg)rr-Zget_keywordsrlrrr�
test_keywords}��
�zMetadataTestCase.test_keywordscCr�)Nr�r�r�r�r�rg)	rrr�r�r3rkrgr�r-r�rrr�test_keywords_invalid_type���
�z+MetadataTestCase.test_keywords_invalid_typecCs0ddddgd�}t|�}|�|��ddg�dS)Nr�r��	GNU/Linux�Some Evil Platform�rZr[rh)rr-Z
get_platformsrlrrr�test_platforms�r�zMetadataTestCase.test_platformscCr�)Nr�r�)r�r�r�r�rh)	rrr�r�r3rkrhr�r-r�rrr�test_platforms_invalid_types�r�z-MetadataTestCase.test_platforms_invalid_typescCs.dddd�}t|�}|�|�}|�d|�dS)Nr�r�zhttp://example.org/boa)rZr[�download_urlr�)rr�r�r�rrr�test_download_url�s�
z"MetadataTestCase.test_download_urlcCsDt�d�}dd|d�}t|�}|�|�}|�dd�}|�||�dS)Nzc        example::
              We start here
            and continue here
          and end here.r�r�)rZr[�long_descriptionz	
        �
)�textwrap�dedentrr��replacer�)rZ	long_descr_rdr�rrr�test_long_description�s
�
z&MetadataTestCase.test_long_descriptionc	Cs�tjdkrd}nd}|��}tj�||�}t|d�}z|�d�W|��n|��wz@t�}t	j
dvrC|tjd<|��}|�
||�t	j
dkrd|tjd	<|��}|�
||d
||f�Wt�|�dSWt�|�dSt�|�w)Nrvrwrxr7�.)�linux�darwin�HOME�win32�USERPROFILEz%r not found in %r)rArZr|ryr}rCr~rSrr�platform�environrr��remove)rr�Ztemp_dirrKrdr�rrr�test_custom_pydistutils�s0






��z(MetadataTestCase.test_custom_pydistutilscCs4ddg}t|�}|�|dd�|�|dd�dS)N)�a�b�cr()r���r)r�r�r�r)rr�r�)rr-)rZhelp_tuplesZ
fancy_optionsrrr�test_fix_help_options�sz&MetadataTestCase.test_fix_help_optionscCs~|�tjtjj�t�}gt_d|_d|_	t
��}|��Wd�n1s'wYdd�|���
d�D�}|�|�dS)Nrzsetup.pycSsg|]
}|��dkr|�qS)rR)�strip)�.0�linerrr�
<listcomp>�s�z3MetadataTestCase.test_show_help.<locals>.<listcomp>r�)r@rZ
set_thresholdZ_global_logZ	thresholdrrr �helpZscript_namerr'r��splitZ
assertTrue)rrd�s�outputrrr�test_show_help�s
�zMetadataTestCase.test_show_helpcCs�dddddddgdgd	�}t|�}|j}t��}|�|�|�d
�|�|�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jddg�|�|j
dg�|�|jd�|�|jdg�dS)Nr�r�ZdescrYzhttp://example.comrirjZfoo)rZr[r��descriptionr�rgr�rZUNKNOWN)rrkr�r�r��seekZ
read_pkg_filer-rZr[r�r�rgrhr�r�)rr_rdrkZPKG_INFOrrr�test_read_metadata�s,�


z#MetadataTestCase.test_read_metadata)rrrrr%r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr!rr�s2
	#r�cCs,t��}|�t�t��|�t�t��|Sr)�unittestZ	TestSuiteZaddTestZ	makeSuiterr�)Zsuiterrr�
test_suite
sr��__main__) rAr�rr�rar�rZdistutils.distrrZ
distutils.cmdrZtest.supportrrrZtest.support.os_helperr	Zdistutils.testsr
Z	distutilsrrrZLoggingSilencerZTempdirManagerZEnvironGuardZTestCaserr�r�rrrrr�<module>s>�T��