Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib64/python3.10/distutils/tests/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/distutils/tests/__pycache__/test_dist.cpython-310.opt-2.pyc

o

0�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�@/opt/alt/python310/lib64/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)
NZinstallz/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_datar9�exec_prefix�home�user�rootz/b)rr r,�
addCleanup�os�unlinkr	�open�print�formatrZpatchZmultipler)r-�sortedZcommand_options�get�keys�items�assertNotIn)	rZfakepath�f�valuesr(Z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*r6z[global]r7z!command_packages = foo.bar, splat)r+r1Zsplat)r0�sporkr*rr+rO)r0�r*)
rr r,r?r@rAr	rBrC�closer)r-r.)rrJr(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�versionZurl�options��attrsrrZ)	r?�setattr�warningsrVrr-�lenrI�dir)rrU�distrrTr�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-�metadatarerd�rr\rarrr�test_finalize_options�s�
�
z*DistributionTestCase.test_finalize_optionscCs\t�}|�|jd�|��}|�|dg�|�|jdg�d|_|��}|�|gd��dS)Nr+rc)r+rfrg)rr-Zcommand_packagesr.)rraZcmdsrrr�test_get_command_packages�s�z.DistributionTestCase.test_get_command_packagescCs(t�}d}ddi}|�t|j||�dS)N)�ok�levelZok2)r�assertRaises�
ValueErrorZannounce)rra�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.cfgr6z[distutils]
cs�Srr)�path�Z	temp_homerr�	_expander�szFDistributionTestCase.test_find_config_files_disable.<locals>._expanderZscript_argsz
--no-user-cfgr[r)�mkdtempr@rXrv�joinrB�write�
expanduserrrr-r_)r�
user_filenamerJrxZold_expanderr(Z	all_files�filesrrwr�test_find_config_files_disable�s"
�
z3DistributionTestCase.test_find_config_files_disable)r)rrrrr%r)r/r5rNrRrbrjrkrrr�
__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�StringIOrh�write_pkg_file�getvalue)rraZsiorrr�format_metadatasz MetadataTestCase.format_metadatacCs\ddd�}t|�}|�|�}|�d|�|�d|���|�d|���|�d|���dS)N�package�1.0)rXrYzMetadata-Version: 1.0�	provides:�	requires:�
obsoletes:)rr��assertInrI�lower�rr\ra�metarrr�test_simple_metadatas�
z%MetadataTestCase.test_simple_metadatacCs|ddddgd�}t|�}|�|j��ddg�|�|��ddg�|�|�}|�d|�|�d|���|�d|���dS)Nr�r�zpackage.sub�rXrYZprovides�Metadata-Version: 1.1r�r�)rr-rhZget_providesr�r�rIr�r�rrr�
test_providess��
�
zMetadataTestCase.test_providescC�|�ttdddgd��dS)Nr�r��my.pkg (splat)r��rnrorrrrr�test_provides_illegal)���z&MetadataTestCase.test_provides_illegalcCs�ddddgd�}t|�}|�|j��ddg�|�|��ddg�|�|�}|�d|�|�d|���|�d|�|�d	|�|�d
|���dS)Nr�r��otherzanother (==1.0)�rXrY�requiresr�r�zRequires: otherzRequires: another (==1.0)r�)rr-rhZget_requiresr�r�rIr�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�)rXr�)�iterrr3rhr��listrirrr�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)�rXrY�	obsoletesr�r�r�zObsoletes: otherzObsoletes: another (<1.0))rr-rhZ
get_obsoletesr�r�rIr�r�rrr�test_obsoletesLs"��
�
zMetadataTestCase.test_obsoletescCr�)Nr�r�r�r�r�rrrr�test_obsoletes_illegal\r�z'MetadataTestCase.test_obsoletes_illegalcCr�)Nr�r�)rXr�)r�rr3rhr�r�rirrr�test_obsoletes_to_listbr�z'MetadataTestCase.test_obsoletes_to_listcCsBdddgd�}t|�}|�|��dg�|�|�}|�d|�dS)N�Boa�3.0�#Programming Language :: Python :: 3�rXrY�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�r3rhr�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�rXrYrd)rr-Zget_keywordsrirrr�
test_keywords}��
�zMetadataTestCase.test_keywordscCr�)Nr�r�r�r�r�rd)	rrr�r�r3rhrdr�r-r�rrr�test_keywords_invalid_type���
�z+MetadataTestCase.test_keywords_invalid_typecCs0ddddgd�}t|�}|�|��ddg�dS)Nr�r��	GNU/Linux�Some Evil Platform�rXrYre)rr-Z
get_platformsrirrr�test_platforms�r�zMetadataTestCase.test_platformscCr�)Nr�r�)r�r�r�r�re)	rrr�r�r3rhrer�r-r�rrr�test_platforms_invalid_types�r�z-MetadataTestCase.test_platforms_invalid_typescCs.dddd�}t|�}|�|�}|�d|�dS)Nr�r�zhttp://example.org/boa)rXrY�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�)rXrY�long_descriptionz	
        �
)�textwrap�dedentrr��replacer�)rZ	long_descr\rar�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)Nrsrtrur6�.)Zlinux�darwin�HOMEZwin32ZUSERPROFILEz%r not found in %r)r@rXryrvrzrBr{rQrr�platform�environrr��remove)rr}Ztemp_dirrJrar~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)rP)�strip)�.0�linerrr�
<listcomp>�s�z3MetadataTestCase.test_show_help.<locals>.<listcomp>r�)r?rZ
set_thresholdZ_global_logZ	thresholdrrr �helpZscript_namerr'r��splitZ
assertTrue)rra�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�ZdescrWzhttp://example.comrfrgZfoo)rXrYr��descriptionr�rdr�rZUNKNOWN)rrhr�r�r��seekZ
read_pkg_filer-rXrYr�r�rdrer�r�)rr\rarhZPKG_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__) r@r�rr�r^r�rZdistutils.distrrZ
distutils.cmdrZtest.supportrrrZtest.support.os_helperr	Zdistutils.testsr
Z	distutilsrrrZLoggingSilencerZTempdirManagerZEnvironGuardZTestCaserr�r�rrrrr�<module>s>�T��