B
    18\                 @   s   d Z ddlZddlZddlZddlZddlm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d	lmZ ddlm
Z
 G d
d de
je
jejZdd Zedkree  dS )zTests for distutils.spawn.    N)mock)run_unittest
unix_shell)support)find_executable)_nt_quote_args)spawn)DistutilsExecErrorc               @   s6   e Zd Zdd Zeejdkddd Zdd Z	d	S )
SpawnTestCasec             C   sF   x@ddgddgfddgddgffD ]\}}t |}| || q"W d S )Nz
with spaceZnospacez"with space"Znochange)r   assertEqual)selfargswantedres r   ^/oak/stanford/groups/akundaje/marinovg/programs/Python-3.7.3/Lib/distutils/tests/test_spawn.pytest_nt_quote_args   s    z SpawnTestCase.test_nt_quote_args)ntposixzRuns only under posix or ntc             C   s   |   }tjdkr2tj|d}| |dt  ntj|d}| |d t|d | 	t
t|g tjdkrtj|d}| |dt  ntj|d}| |d t|d t|g d S )	Nwin32zfoo.shz#!%s
exit 1zfoo.batzexit 1i  z#!%s
exit 0zexit 0)mkdtempsysplatformospathjoin
write_filer   chmodassertRaisesr	   r   )r   tmpdirexer   r   r   
test_spawn   s    

zSpawnTestCase.test_spawnc             C   s&  t  }t j}|d }tj||}t|d W d Q R X t|tj	 t
||d}| || tjdkrt
||d}| || t | t
|}| || W d Q R X d| }t
||d}| | t  <}td|$ |d t
|}| || W d Q R X W d Q R X W d Q R X d S )Nz.exewb)r   r   Z
dontexist_zdistutils.spawn.os.defpathPATH)test_supporttemp_dirTESTFNr   r   r   openr   statS_IXUSRr   r   r   r   
change_cwdassertIsNoneEnvironmentVarGuardr   patchpop)r   tmp_dirZprogram_noeextprogramfilenamervZdont_exist_programenvr   r   r   test_find_executable:   s.    




z"SpawnTestCase.test_find_executableN)
__name__
__module____qualname__r   unittest
skipUnlessr   namer!   r4   r   r   r   r   r
      s   
r
   c               C   s
   t tS )N)r8   	makeSuiter
   r   r   r   r   
test_suitec   s    r<   __main__)__doc__r   r(   r   r8   r   Ztest.supportr   r   testr   r$   distutils.spawnr   r   r   Zdistutils.errorsr	   distutils.testsTempdirManagerLoggingSilencerTestCaser
   r<   r5   r   r   r   r   <module>   s$   Q