Your IP : 216.73.216.85


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_script_helper.cpython-39.opt-1.pyc

a

XC?h�@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)N�-c�import sys; sys.exit(0)rzreturn code was not 0)r�assert_python_ok�assertEqual)�self�t�r�</opt/alt/python39/lib64/python3.9/test/test_script_helper.py�test_assert_python_ok
sz&TestScriptHelper.test_assert_python_okcCs$t�dd�\}}}|�d|d�dS)Nr�sys.exit(0)rzreturn code should not be 0)r�assert_python_failureZassertNotEqual)r	Zrc�out�errrrr�test_assert_python_failuresz+TestScriptHelper.test_assert_python_failurecCs`|�t��}t�dd�Wd�n1s,0Yt|j�}|�d|�|jd|dd�dS)Nrrz
command line:zunexpected command line��msg)�assertRaises�AssertionErrorrr�str�	exception�assertIn�r	Z
error_contextZ	error_msgrrr�test_assert_python_ok_raisess
*
z-TestScriptHelper.test_assert_python_ok_raisescCs`|�t��}t�dd�Wd�n1s,0Yt|j�}|�d|�|jd|dd�dS)NrrzProcess return code is 0
zunexpected command line.r)rrrrrrrrrrr�!test_assert_python_failure_raisess*
�z2TestScriptHelper.test_assert_python_failure_raiseszsubprocess.PopencCs�tjjtddd���}td�|_zt�ddd�Wn6tyf}z|�d|jd�WYd}~n
d}~00|�d	|j	�|�d	|j	�|j
dd}|�tj|d�|�
d|�|�
d
|�|�d|�Wd�n1s�0YdS)N� interpreter_requires_environmentF�Zreturn_value�bail out of unittestTr�Noner��-I�-E)r�patch�objectr�RuntimeError�side_effect�_assert_pythonr�args�
call_count�	call_args�sys�
executabler�assertNotIn�r	Z
mock_popenZ
mock_ire_funcrZ
popen_commandrrr�1test_assert_python_isolated_when_env_not_required&s"�
(zBTestScriptHelper.test_assert_python_isolated_when_env_not_requiredcCs�tjjtddd���}td�|_zt�ddd�Wn6tyf}z|�d|jd�WYd}~n
d}~00|j	dd}|�
d	|�|�
d
|�Wd�n1s�0YdS)z>Ensure that -I is not passed when the environment is required.rTrrrr rNr"r#)rr$r%rr&r'r(rr)r+r.r/rrr�4test_assert_python_not_isolated_when_env_is_required8s�
(zETestScriptHelper.test_assert_python_not_isolated_when_env_is_requiredN)�__name__�
__module__�__qualname__r
rrrrr$r0r1rrrr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�NZ$__cached_interp_requires_environment)�
assertTrue�hasattrr�__dict__�r	rrr�setUpKs�z!TestScriptHelperEnvironment.setUpcCsdtjd<dSr6)rr9r:rrr�tearDownQsz$TestScriptHelperEnvironment.tearDownzsubprocess.check_callcCsxtj�tj��Vtj�dd�t�dd�|_|�	t
���|�	t
���|�d|j
�Wd�n1sj0YdS)N�
PYTHONHOME�r!)rr$�dict�os�environ�pop�
subprocessZCalledProcessErrorr'r7rrrr*�r	�mock_check_callrrr�*test_interpreter_requires_environment_trueUszFTestScriptHelperEnvironment.test_interpreter_requires_environment_truecCsdtj�tj��Btj�dd�t��|�t���|�	d|j
�Wd�n1sV0YdS)Nr=r!)rr$r?r@rArBrr�assertFalserr*rDrrr�+test_interpreter_requires_environment_false^s
zGTestScriptHelperEnvironment.test_interpreter_requires_environment_falsecCs�tj�tj��|tj�dd�t��|�t���|�t���|�	d|j
�|jdd}|�	tj
|d�|�d|�Wd�n1s�0YdS)Nr=r!rr#)rr$r?r@rArBrrrGrr*r+r,r-r)r	rEZcheck_call_commandrrr�-test_interpreter_requires_environment_detailsgszITestScriptHelperEnvironment.test_interpreter_requires_environment_detailscCsftj�tj��Ddtjd<|�t���|�t���|�d|j	�Wd�n1sX0YdS)NZ
MockedHomer=r)
rr$r?r@rAr7rrrr*rDrrr�5test_interpreter_requires_environment_with_pythonhomess

zQTestScriptHelperEnvironment.test_interpreter_requires_environment_with_pythonhomeN)r2r3r4�__doc__r;r<rr$rFrHrIrJrrrrr5Hs


r5�__main__)
rKrCr,r@Ztest.supportrZunittestrZTestCaserr5r2�mainrrrr�<module>s=4