Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_code_module.cpython-34.pyo

�
g f��@s�dZddlZddlZddlmZddlmZddlmZejd�Z	Gdd�dej
�Zd	d
�Ze
dkr�ej�ndS)zCTest InteractiveConsole and InteractiveInterpreter from code module�N)�	ExitStack)�mock)�support�codec@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�TestInteractiveConsolecCstj�|_|j�dS)N)rZInteractiveConsole�console�mock_sys)�self�r
�:/opt/alt/python34/lib64/python3.4/test/test_code_module.py�setUp
szTestInteractiveConsole.setUpcCs�t�}|j|j�|jtjddd��|_|jtjd��|_|jtjd��|_tjddt	j
dt	j
�}|j|�|_t
jt
j
kr�|jj
|j_nd	S)
z.Mock system environment for InteractiveConsolez
code.input�createTzcode.sys.stdoutzcode.sys.stderrzcode.sys�wraps�specN)rZ
addCleanup�close�
enter_contextrZpatch�infunc�stdout�stderrr�sys�sysmod�
excepthook�__excepthook__)r	�stackZprepatchr
r
rrs	!zTestInteractiveConsole.mock_syscCs9td�|j_|jj�|j|jjd�dS)N�Finishedz>>> )�EOFErrorr�side_effectr�interact�assertEqualrZps1)r	r
r
r�test_ps1s
zTestInteractiveConsole.test_ps1cCs9td�|j_|jj�|j|jjd�dS)Nrz... )rrrrrrrZps2)r	r
r
r�test_ps2$s
zTestInteractiveConsole.test_ps2cCsrddtd�g|j_|jj�xCt|jj�D]#}ddj|d�kr;Pq;q;Wt	d��dS)Nz	'antioch'�rZantioch�zno console stdout)
rrrrr�listr�method_calls�join�AssertionError)r	�callr
r
r�test_console_stderr)s
z*TestInteractiveConsole.test_console_stderrcCsidtd�g|j_|jj�x=|jjD]#}ddj|d�kr2Pq2q2Wtd��dS)NZ	undefinedr�	NameErrorr!r"zNo syntax error from console)	rrrrrrr$r%r&)r	r'r
r
r�test_syntax_error2s
z(TestInteractiveConsole.test_syntax_errorcCsQdtd�g|j_tj�}||j_|jj�|j	|j
�dS)Nzraise ValueError('')r)rrrrZMockrrrrZ
assertTrueZcalled)r	�hookr
r
r�test_sysexcepthook;s
z)TestInteractiveConsole.test_sysexcepthookcCs�td�|j_|jjdd�|jt|jj�d�|jjd}|j|dd
ig�|jj	�td�|j_|jjdd�|jt|jj�d	�dS)NrZbannerZFoo�r�write�Foo
r!r")r/)
rrrrrr�lenrr$Z
reset_mock)r	Zbanner_callr
r
r�test_bannerCs
z"TestInteractiveConsole.test_bannerN)�__name__�
__module__�__qualname__rrrr r(r*r,r1r
r
r
rrs		rcCstjt�dS)N)rZrun_unittestrr
r
r
r�	test_mainRsr5�__main__)�__doc__rZunittest�
contextlibrrZtestr�
import_modulerZTestCaserr5r2�mainr
r
r
r�<module>sG