o
    JAf”  ã                   @   sž   	 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rMeeƒ ƒ dS dS )é    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u d	¡e ed
ƒdu d¡dd„ ƒƒƒƒZe ej 	d¡d¡e
ƒ e edƒdu d	¡e ed
ƒdu d¡dd„ ƒƒƒƒZ‡  ZS )ÚBuildRpmTestCasec                    s\   zt j d¡ W n ty   t d¡‚w 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__© ú5/usr/lib/python3.10/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   ÚtearDownr   r   r   r   r   %   s   zBuildRpmTestCase.tearDownÚ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ÚHOMEZfoozsetup.pyzfoo.pyú#zMANIFEST.inzinclude foo.pyZREADMEÚ z0.1Zxxx)ÚnameÚversionZ
py_modulesÚurlZauthorZ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   Ztmp_dirZpkg_dirr&   ÚcmdZdist_createdr   r   r   Ú
test_quiet-   s2   	

ý
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 r   )r(   r   r)   r*   r+   r,   r-   r.   r   r/   r   r	   r   r   r0   r1   r2   r3   r4   r5   r6   Úremover7   r   r   r   Útest_no_optimize_flagX   s4   


ý
z&BuildRpmTestCase.test_no_optimize_flag)Ú__name__Ú
__module__Ú__qualname__r   r   r   Z
skipUnlessr	   ÚplatformÚ
startswithr   ZskipIfr   r9   r;   Ú__classcell__r   r   r   r   r      s2    
ÿÿÿ$ÿÿÿr   c                   C   s
   t  t¡S )N)r   Z	makeSuiter   r   r   r   r   Ú
test_suiteƒ   s   
rB   Ú__main__)r   r	   r   Ztest.supportr   r   Zdistutils.corer   Zdistutils.command.bdist_rpmr   Zdistutils.testsr   Zdistutils.spawnr   r.   ZTempdirManagerZEnvironGuardZLoggingSilencerZTestCaser   rB   r<   r   r   r   r   Ú<module>   s&    	ýmÿ