HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_script_helper.cpython-37.opt-1.pyc
B

��g�@stdZddlZddlZddlZddlmZddlZddlmZGdd�dej�Z	Gdd�dej�Z
ed	krpe��dS)
zEUnittests for test.support.script_helper.  Who tests the test helper?�N)�
script_helper)�mockc@sPeZdZdd�Zdd�Zdd�Zdd�Ze�d	�d
d��Z	e�d	�dd
��Z
dS)�TestScriptHelpercCs"t�dd�}|�d|dd�dS)Nz-czimport sys; sys.exit(0)rzreturn code was not 0)r�assert_python_ok�assertEqual)�self�t�r	�3/usr/local/lib/python3.7/test/test_script_helper.py�test_assert_python_ok
sz&TestScriptHelper.test_assert_python_okcCs$t�dd�\}}}|�d|d�dS)Nz-czsys.exit(0)rzreturn code should not be 0)r�assert_python_failureZassertNotEqual)rZrc�out�errr	r	r
�test_assert_python_failuresz+TestScriptHelper.test_assert_python_failurec	CsL|�t��}t�dd�WdQRXt|j�}|�d|�|jd|dd�dS)Nz-czsys.exit(0)z
command line:zunexpected command line)�msg)�assertRaises�AssertionErrorrr�str�	exception�assertIn)r�
error_context�	error_msgr	r	r
�test_assert_python_ok_raisess

z-TestScriptHelper.test_assert_python_ok_raisesc	CsL|�t��}t�dd�WdQRXt|j�}|�d|�|jd|dd�dS)Nz-czimport sys; sys.exit(0)zProcess return code is 0
zunexpected command line.)r)rrrrrrr)rrrr	r	r
�!test_assert_python_failure_raisess
z2TestScriptHelper.test_assert_python_failure_raiseszsubprocess.PopencCs�tjjtddd���}td�|_yt�ddd�Wn4tk
rd}z|�d|jd�Wdd}~XYnX|�d	|j	�|�d	|j	�|j
dd}|�tj|d�|�
d|�|�
d
|�|�d|�WdQRXdS)N� interpreter_requires_environmentF)�return_valuezbail out of unittestTz-c�Noner�z-Iz-E)r�patch�objectr�RuntimeError�side_effect�_assert_pythonr�args�
call_count�	call_args�sys�
executabler�assertNotIn)r�
mock_popen�
mock_ire_funcr�
popen_commandr	r	r
�1test_assert_python_isolated_when_env_not_required&s

$zBTestScriptHelper.test_assert_python_isolated_when_env_not_requiredcCs�tjjtddd��~}td�|_yt�ddd�Wn4tk
rd}z|�d|jd�Wdd}~XYnX|j	dd}|�
d	|�|�
d
|�WdQRXdS)z>Ensure that -I is not passed when the environment is required.rT)rzbail out of unittestz-crrNz-Iz-E)rrrrr r!r"rr#r%r()rr)r*rr+r	r	r
�4test_assert_python_not_isolated_when_env_is_required8s

$zETestScriptHelper.test_assert_python_not_isolated_when_env_is_requiredN)�__name__�
__module__�__qualname__rrrrrrr,r-r	r	r	r
rsrc@sheZdZdZdd�Zdd�Ze�d�dd��Ze�d�d	d
��Z	e�d�dd��Z
e�d�d
d��ZdS)�TestScriptHelperEnvironmentz5Code coverage for interpreter_requires_environment().cCs|�ttd��dtjd<dS)N�$__cached_interp_requires_environment)�
assertTrue�hasattrr�__dict__)rr	r	r
�setUpKsz!TestScriptHelperEnvironment.setUpcCsdtjd<dS)Nr2)rr5)rr	r	r
�tearDownQsz$TestScriptHelperEnvironment.tearDownzsubprocess.check_callc	Csdtj�tj��Ltj�dd�t�dd�|_|�	t
���|�	t
���|�d|j
�WdQRXdS)N�
PYTHONHOME�r)rr�dict�os�environ�pop�
subprocessZCalledProcessErrorr!r3rrrr$)r�mock_check_callr	r	r
�*test_interpreter_requires_environment_trueUszFTestScriptHelperEnvironment.test_interpreter_requires_environment_truec	CsPtj�tj��8tj�dd�t��|�t���|�	d|j
�WdQRXdS)Nr8r)rrr:r;r<r=rr�assertFalserr$)rr?r	r	r
�+test_interpreter_requires_environment_false^s
zGTestScriptHelperEnvironment.test_interpreter_requires_environment_falsec	Cs�tj�tj��rtj�dd�t��|�t���|�t���|�	d|j
�|jdd}|�	tj
|d�|�d|�WdQRXdS)Nr8rrz-E)rrr:r;r<r=rrrArr$r%r&r'r)rr?Zcheck_call_commandr	r	r
�-test_interpreter_requires_environment_detailsgszITestScriptHelperEnvironment.test_interpreter_requires_environment_detailsc	CsRtj�tj��:dtjd<|�t���|�t���|�d|j	�WdQRXdS)NZ
MockedHomer8r)
rrr:r;r<r3rrrr$)rr?r	r	r
�5test_interpreter_requires_environment_with_pythonhomess

zQTestScriptHelperEnvironment.test_interpreter_requires_environment_with_pythonhomeN)r.r/r0�__doc__r6r7rrr@rBrCrDr	r	r	r
r1Hs		r1�__main__)
rEr>r&r;Ztest.supportrZunittestrZTestCaserr1r.�mainr	r	r	r
�<module>s=4