B
    Ûö›\  ã               @   sœ   d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dZG d	d
„ d
ejejejejƒZdd„ Zedkr˜eeƒ ƒ dS )z&Tests for distutils.command.bdist_rpm.é    N)Úrun_unittestÚrequires_zlib)ÚDistribution)Ú	bdist_rpm)Úsupport)Úfind_executablez–from distutils.core import setup
import foo

setup(name='foo', version='0.1', py_modules=['foo'],
      url='xxx', author='xxx', author_email='xxx')

c                   s¸   e Zd Z‡ fdd„Z‡ fdd„Ze ej 	d¡d¡e
e edƒdkd	¡e ed
ƒdkd¡dd„ ƒƒƒƒZe ej 	d¡d¡e
e edƒdkd	¡e ed
ƒdkd¡dd„ ƒƒƒƒZ‡  ZS )ÚBuildRpmTestCasec                sb   yt j d¡ W n tk
r.   t d¡‚Y nX tt| ƒ ¡  t	 
¡ | _t jt jd d … f| _d S )NzUTF-8z(sys.executable is not encodable to UTF-8)ÚsysÚ
executableÚencodeÚUnicodeEncodeErrorÚunittestZSkipTestÚsuperr   ÚsetUpÚosÚgetcwdÚold_locationÚargvÚold_sys_argv)Úself)Ú	__class__© ú/lib/python3.7/distutils/tests/test_bdist_rpm.pyr      s    
zBuildRpmTestCase.setUpc                s>   t  | j¡ | jd t_| jd tjd d …< tt| ƒ ¡  d S )Nr   é   )	r   Úchdirr   r   r	   r   r   r   ÚtearDown)r   )r   r   r   r   %   s    zBuildRpmTestCase.tearDownZlinuxz,spurious sdtout/stderr output under Mac OS XZrpmNzthe rpm command is not foundZrpmbuildz!the rpmbuild command is not foundc             C   sþ   |   ¡ }|tjd< tj |d¡}t |¡ |  |dft¡ |  |dfd¡ |  |dfd¡ |  |dfd	¡ tdd
dgddddœƒ}d|_	t 
|¡ dgt_t|ƒ}d|_d|_| ¡  | ¡  t tj |d¡¡}|  d|¡ |  d|j¡ |  d|j¡ d S )NÚHOMEÚfoozsetup.pyzfoo.pyú#zMANIFEST.inzinclude foo.pyÚREADMEÚ z0.1Úxxx)ÚnameÚversionÚ
py_modulesÚurlÚauthorÚauthor_emailTr   Údistzfoo-0.1-1.noarch.rpm)r   Úanyzdist/foo-0.1-1.src.rpm)r   r)   zdist/foo-0.1-1.noarch.rpm)Úmkdtempr   ÚenvironÚpathÚjoinÚmkdirÚ
write_fileÚSETUP_PYr   Úscript_namer   r	   r   r   Ú
fix_pythonÚquietÚensure_finalizedÚrunÚlistdirÚassertInÚ
dist_files)r   Útmp_dirÚpkg_dirr(   ÚcmdÚdist_createdr   r   r   Ú
test_quiet-   s0    	



zBuildRpmTestCase.test_quietc             C   s  |   ¡ }|tjd< tj |d¡}t |¡ |  |dft¡ |  |dfd¡ |  |dfd¡ |  |dfd	¡ tdd
dgddddœƒ}d|_	t 
|¡ dgt_t|ƒ}d|_d|_| ¡  | ¡  t tj |d¡¡}|  d|¡ |  d|j¡ |  d|j¡ t tj |dd¡¡ d S )Nr   r   zsetup.pyzfoo.pyr   zMANIFEST.inzinclude foo.pyr   r    z0.1r!   )r"   r#   r$   r%   r&   r'   Tr   r(   zfoo-0.1-1.noarch.rpm)r   r)   zdist/foo-0.1-1.src.rpm)r   r)   zdist/foo-0.1-1.noarch.rpm)r*   r   r+   r,   r-   r.   r/   r0   r   r1   r   r	   r   r   r2   r3   r4   r5   r6   r7   r8   Úremove)r   r9   r:   r(   r;   r<   r   r   r   Útest_no_optimize_flagX   s2    




z&BuildRpmTestCase.test_no_optimize_flag)Ú__name__Ú
__module__Ú__qualname__r   r   r   Z
skipUnlessr	   ÚplatformÚ
startswithr   ZskipIfr   r=   r?   Ú__classcell__r   r   )r   r   r      s    
%r   c               C   s
   t  t¡S )N)r   Z	makeSuiter   r   r   r   r   Ú
test_suiteƒ   s    rF   Ú__main__)Ú__doc__r   r	   r   Ztest.supportr   r   Zdistutils.corer   Zdistutils.command.bdist_rpmr   Zdistutils.testsr   Zdistutils.spawnr   r0   ZTempdirManagerZEnvironGuardZLoggingSilencerZTestCaser   rF   r@   r   r   r   r   Ú<module>   s    	j