HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/numpy/distutils/tests/__pycache__/test_exec_command.cpython-310.pyc
o

6��a��@s�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
Gdd�d�ZGd	d
�d
�ZGdd�d�Zd
d�Zdd�ZGdd�d�ZdS)�N)�
TemporaryFile)�exec_command)�
get_pythonexe)�tempdir�assert_�assert_warns)�StringIOc@�*eZdZdZd	dd�Zdd�Zdd�ZdS)
�redirect_stdoutz9Context manager to redirect stdout for exec_command test.NcC�|ptj|_dS�N)�sys�stdout�_stdout)�selfr�r�I/usr/lib/python3/dist-packages/numpy/distutils/tests/test_exec_command.py�__init__�zredirect_stdout.__init__cC�tj|_|jt_dSr)r
r�
old_stdoutr�rrrr�	__enter__�zredirect_stdout.__enter__cC� |j��|jt_|j��dSr)r�flushrr
r�close�r�exc_type�	exc_value�	tracebackrrr�__exit__�
zredirect_stdout.__exit__r��__name__�
__module__�__qualname__�__doc__rrr!rrrrr

�

r
c@r	)
�redirect_stderrz9Context manager to redirect stderr for exec_command test.NcCrr)r
�stderr�_stderr)rr*rrrrrzredirect_stderr.__init__cCrr)r
r*�
old_stderrr+rrrrr!rzredirect_stderr.__enter__cCrr)r+rr,r
r*rrrrrr!%r"zredirect_stderr.__exit__rr#rrrrr)r(r)c@s*eZdZdZd
dd�Zdd�Zdd�Zd	S)�emulate_nonposixz.Context manager to emulate os.name != 'posix' �	non-posixcCs
||_dSr)�	_new_name)r�osnamerrrr-s
zemulate_nonposix.__init__cCrr)�os�name�	_old_namer/rrrrr0rzemulate_nonposix.__enter__cCs|jt_dSr)r3r1r2rrrrr!4�zemulate_nonposix.__exit__N)r.r#rrrrr-+r(r-cCsVtt���6tt���!tt��
t�d�Wd�n1s wYWd�n1s/wYWd�n1s>wYtjdkr�t	��Ttt���6tt���!tt��
t�d�Wd�n1slwYWd�n1s{wYWd�n1s�wYWd�dSWd�dS1s�wYdSdS)N�cd '.'�posix)
r
rr)rr�DeprecationWarningrr1r2r-rrrr�test_exec_command_stdout8s0
�����

������"��r8cCsZttdd���6tt���!tt��
t�d�Wd�n1s"wYWd�n1s1wYWd�n1s@wYtjdkr�t	��Ttt���6tt���!tt��
t�d�Wd�n1snwYWd�n1s}wYWd�n1s�wYWd�dSWd�dS1s�wYdSdS)Nzw+)�moder5r6)
r
rr)rrr7rr1r2r-rrrr�test_exec_command_stderrPs0
�����

������"��r:c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestExecCommandcCst�|_dSr)r�pyexerrrr�setupar4zTestExecCommand.setupcKsVt�d�\}}t|dk�t|dk�t�d|j�\}}t|dk�t|dk�dS)Nzcmd /C echo path=%path%r�z3"%s" -c "import sys;sys.stderr.write(sys.platform)"�win32)rrr<�r�kws�s�orrr�check_ntds�zTestExecCommand.check_ntcKstjdi|��\}}t|dk�t|dk�tjdi|��\}}t|dk�t|dk�tjdddi|��\}}t|dk�t|dk�tjdi|��\}}t|dk�t|dk�d	tjvr�d
tjd	<tjdi|��\}}t|dk�t|d
k�tjdd	di|��\}}t|dk�t|dk�tjdi|��\}}t|dk�t|d
k�tjd	=tjdi|��\}}t|dk�t|dk�tjdi|��\}}t|dk�t|dk�tjdi|��\}}t|dk�t|dk�tjd|jfi|��\}}t|dk�t|dk�dS)N�
echo Hellor�Hello�	echo $AAAr>�echo "$AAA"�AAA�Tere�BBB�Hi�echo "$BBB"�Hey�this_is_not_a_command�echo path=$PATHz1"%s" -c "import sys,os;sys.stderr.write(os.name)"r6)rE)rG)rH)rM)rO)rP)rrr1�environr<r@rrr�check_posixnsT

��
�zTestExecCommand.check_posixcGs�tjd|jfi|��\}}t|dk�t|dk�tjd|jfi|��\}}t|dk�t|dk�tjd|jfi|��\}}t|dk�t|dk�tjd|jfi|��\}}t|dk�t|d	k�dS)
Nz"%s" -c "raise 'Ignore me.'"rr>zV"%s" -c "import sys;sys.stderr.write('0');sys.stderr.write('1');sys.stderr.write('2')"�012z!"%s" -c "import sys;sys.exit(15)"�z"%s" -c "print('Heipa'")�Heipa)rr<rr@rrr�check_basic�s<�
���
��
��
�zTestExecCommand.check_basicc	Ks�t��f}d}tj�||�}t|d��
}|�d�Wd�n1s"wYtjd|j|ffi|��\}}t|dk�t|dk�tjd|j|ffd|i|��\}}t|dk�t|dk�Wd�dS1slwYdS)	N�file�wrFz("%s" -c "f = open('%s', 'r'); f.close()"rr>z9"%s" -c "f = open('%s', 'r'); print(f.read()); f.close()"�
execute_in)	rr1�path�join�open�writerr<r)rrA�tmpdir�fn�tmpfile�frBrCrrr�check_execute_in�s6���
����
�"�z TestExecCommand.check_execute_inc
Cs�tt���itt���Ktt��7tjdkr#|jdd�|jdd�ntjdkr4|jdd�|jdd�|j	dd�|j	dd�Wd�n1sJwYWd�n1sYwYWd�dSWd�dS1sqwYdS)Nr6r)�use_tee��nt)
r
rr)rr7r1r2rRrDrbrrrr�
test_basic�s"


����"�zTestExecCommand.test_basicN)	r$r%r&r=rDrRrVrbrfrrrrr;`s
4r;)r1r
�tempfiler�numpy.distutilsr�numpy.distutils.exec_commandr�
numpy.testingrrr�iorr
r)r-r8r:r;rrrr�<module>s