Your IP : 216.73.216.213


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.opt-2.pyc



���]�@s�ddlZddlZddlmZddlZddlmZGdd�dej�ZGdd�dej�Ze	dkr�ej
�dS)	�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	�7/opt/alt/python35/lib64/python3.5/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)
NrrTzbail out of unittestz-crrz-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@syeZdZdd�Zdd�Zejd�dd��Zejd�dd	��Zejd�d
d��Z	dS)
�TestScriptHelperEnvironmentcCs'|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)�
subprocess�CalledProcessErrorr"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/r0r1r7r8rrr=r?r@r	r	r	r
r2Gs
r2�__main__)r:r'Ztest.supportrZunittestrZTestCaserr2r/�mainr	r	r	r
�<module>s=&