Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_code_module.cpython-39.pyc

a

��g�@stdZddlZddlZddlmZddlmZddlmZddlm	Z	e	�
d�ZGdd	�d	ej�Z
ed
krpe��dS)zCTest InteractiveConsole and InteractiveInterpreter from code module�N)�dedent)�	ExitStack)�mock)�support�codec@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestInteractiveConsolecCst��|_|��dS)N)rZInteractiveConsole�console�mock_sys��self�r�1/usr/local/lib/python3.9/test/test_code_module.py�setUps
zTestInteractiveConsole.setUpcCs�t�}|�|j�|�tjddd��|_|�t�d��|_|�t�d��|_tjdt	j
t	j
d�}|�|�|_t
jt
j
ur�|jj
|j_|j`|j`dS)	z.Mock system environment for InteractiveConsolez
code.inputT)Zcreatezcode.sys.stdoutzcode.sys.stderrzcode.sys)�wraps�specN)rZ
addCleanup�close�
enter_contextrZpatch�infunc�stdout�stderrr�sys�sysmod�
excepthook�__excepthook__�ps1�ps2)r�stackZprepatchrrr
r	s
�
zTestInteractiveConsole.mock_syscCsLtd�|j_|j��|�|jjd�d|j_|j��|�|jjd�dS)N�Finishedz>>> z	custom1> )�EOFErrorr�side_effectr�interact�assertEqualrrr
rrr
�test_ps1"s

zTestInteractiveConsole.test_ps1cCsLtd�|j_|j��|�|jjd�d|j_|j��|�|jjd�dS)Nrz... z	custom2> )	rrrrr r!rrrr
rrr
�test_ps2*s

zTestInteractiveConsole.test_ps2cCsPddtd�g|j_|j��t|jj�D]}dd�|d�vr(qLq(t	d��dS)Nz	'antioch'�rZantioch�zno console stdout)
rrrrr �listr�method_calls�join�AssertionError�r�callrrr
�test_console_stderr2s
z*TestInteractiveConsole.test_console_stderrcCsJdtd�g|j_|j��|jjD]}dd�|d�vr"qFq"td��dS)NZ	undefinedr�	NameErrorr$r%zNo syntax error from console)	rrrrr rr'r(r)r*rrr
�test_syntax_error;s
z(TestInteractiveConsole.test_syntax_errorcCs:dtd�g|j_t��}||j_|j��|�	|j
�dS)Nzraise ValueError('')r)rrrrZMockrrrr Z
assertTrueZcalled)r�hookrrr
�test_sysexcepthookDs�
z)TestInteractiveConsole.test_sysexcepthookcCs�td�|j_|jjdd�|�t|jj�d�|jjd}|�|ddig�|j�	�td�|j_|jjdd�|�t|jj�d	�dS)
NrZFoo��banner�r�write)zFoo
r$��
rrrrr r!�lenrr'Z
reset_mock)rZbanner_callrrr
�test_bannerLs
z"TestInteractiveConsole.test_bannercCs�td�|j_|jjdd�|�t|jj�d�|jjd}d}|�|d|fig�|j�	�td�|j_|jjddd�|�t|jj�d�|j�	�d	}td�|j_|jjd|d�|�t|jj�d�|jjd}|d
}|�|d|fig�dS)Nrr$r1r5r%z"now exiting InteractiveConsole...
r4)r2Zexitmsgu	bye! ζж�
r6)r�err_msg�expected�messagerrr
�
test_exit_msgZs&

�z$TestInteractiveConsole.test_exit_msgcCsJdtd�g|j_|j��d�dd�|jjD��}td�}|�	||�dS)Nz(raise ValueError('') from AttributeErrorrr$css|]}d�|d�VqdS�r$r%N�r(��.0r+rrr
�	<genexpr>z�z7TestInteractiveConsole.test_cause_tb.<locals>.<genexpr>z�
        AttributeError

        The above exception was the direct cause of the following exception:

        Traceback (most recent call last):
          File "<console>", line 1, in <module>
        ValueError
        �
rrrrr r(rr'rZassertIn�r�outputr;rrr
�
test_cause_tbvs�
	z$TestInteractiveConsole.test_cause_tbcCsJdtd�g|j_|j��d�dd�|jjD��}td�}|�	||�dS)Nztry: ham
except: eggs
rr$css|]}d�|d�VqdSr>r?r@rrr
rB�rCz9TestInteractiveConsole.test_context_tb.<locals>.<genexpr>ah
        Traceback (most recent call last):
          File "<console>", line 1, in <module>
        NameError: name 'ham' is not defined

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "<console>", line 2, in <module>
        NameError: name 'eggs' is not defined
        rDrErrr
�test_context_tb�s�
z&TestInteractiveConsole.test_context_tbN)�__name__�
__module__�__qualname__rr	r"r#r,r.r0r8r=rGrHrrrr
rs		r�__main__)�__doc__rZunittest�textwrapr�
contextlibrr�testr�
import_modulerZTestCaserrI�mainrrrr
�<module>s


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists