Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_script_helper.cpython-35.pyc



��Yf�@s�dZddlZddlZddlmZddlZddlmZGdd�dej�ZGdd�dej�Z	e
d	kr�ej�dS)
zEUnittests for test.support.script_helper.  Who tests the test helper?�N)�
script_helper)�mockc@sveZdZdd�Zdd�Zdd�Zdd�Zejd	�d
d��Z	ejd	�dd
��Z
dS)�TestScriptHelpercCs-tjdd�}|jd|dd�dS)Nz-czimport sys; sys.exit(0)rzreturn code was not 0)r�assert_python_ok�assertEqual)�self�t�r	�</opt/alt/python35/lib64/python3.5/test/test_script_helper.py�test_assert_python_oksz&TestScriptHelper.test_assert_python_okcCs2tjdd�\}}}|jd|d�dS)Nz-czsys.exit(0)rzreturn code should not be 0)r�assert_python_failureZassertNotEqual)r�rc�out�errr	r	r
�test_assert_python_failuresz+TestScriptHelper.test_assert_python_failurecCsb|jt��}tjdd�WdQRXt|j�}|jd|�|jd|dd�dS)Nz-czsys.exit(0)z
command line:�msgzunexpected command line)�assertRaises�AssertionErrorrr�str�	exception�assertIn)r�
error_context�	error_msgr	r	r
�test_assert_python_ok_raisess
z-TestScriptHelper.test_assert_python_ok_raisescCsb|jt��}tjdd�WdQRXt|j�}|jd|�|jd|dd�dS)Nz-czimport sys; sys.exit(0)zProcess return code is 0
rzunexpected command line.)rrrrrrr)rrrr	r	r
�!test_assert_python_failure_raisessz2TestScriptHelper.test_assert_python_failure_raiseszsubprocess.PopencCstjjtddd���}td�|_ytjddd�Wn<tk
r�}z|jd|jd�WYdd}~XnX|jd	|j	�|jd	|j	�|j
dd}|jtj|d�|j
d|�|j
d
|�|jd|�WdQRXdS)N� interpreter_requires_environment�return_valueFzbail 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�|_ytjddd�Wn<tk
r�}z|jd|jd�WYdd}~XnX|j	dd}|j
d	|�|j
d
|�WdQRXdS)z>Ensure that -I is not passed when the environment is required.rrTzbail out of unittestz-crrNz-Iz-E)rrr rr!r"r#rr$r&r))rr*r+rr,r	r	r
�4test_assert_python_not_isolated_when_env_is_required7s*zETestScriptHelper.test_assert_python_not_isolated_when_env_is_requiredN)�__name__�
__module__�__qualname__rrrrrrr-r.r	r	r	r
r
src@seZdZdZdd�Zdd�Zejd�dd��Zejd�d	d
��Z	ejd�dd��Z
d
S)�TestScriptHelperEnvironmentz5Code coverage for interpreter_requires_environment().cCs'|jttd��dtjd<dS)N�$__cached_interp_requires_environment)�
assertTrue�hasattrr�__dict__)rr	r	r
�setUpJsz!TestScriptHelperEnvironment.setUpcCsdtjd<dS)Nr3)rr6)rr	r	r
�tearDownPsz$TestScriptHelperEnvironment.tearDownzsubprocess.check_callcCsRtjdd�|_|jtj��|jtj��|jd|j�dS)N�r)�
subprocessZCalledProcessErrorr"r4rrrr%)r�mock_check_callr	r	r
�*test_interpreter_requires_environment_trueTszFTestScriptHelperEnvironment.test_interpreter_requires_environment_truecCs4tj�|jtj��|jd|j�dS)Nr)rr�assertFalserr%)rr;r	r	r
�+test_interpreter_requires_environment_false[s
zGTestScriptHelperEnvironment.test_interpreter_requires_environment_falsecCstj�|jtj��|jtj��|jd|j�|jdd}|jtj|d�|jd|�dS)Nrrz-E)	rrr=rr%r&r'r(r)rr;Zcheck_call_commandr	r	r
�-test_interpreter_requires_environment_detailsbs
zITestScriptHelperEnvironment.test_interpreter_requires_environment_detailsN)r/r0r1�__doc__r7r8rrr<r>r?r	r	r	r
r2Gsr2�__main__)r@r:r'Ztest.supportrZunittestrZTestCaserr2r/�mainr	r	r	r
�<module>s=&