HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_code_module.cpython-37.opt-2.pyc
B

��g�@spddlZddlZddlmZddlmZddlmZddlmZe�	d�Z
Gdd�dej�Ze
d	krle��dS)
�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.7/test/test_code_module.py�setUps
zTestInteractiveConsole.setUpcCs�t�}|�|j�|�tjddd��|_|�t�d��|_|�t�d��|_tjdt	j
t	j
d�}|�|�|_t
jt
j
kr�|jj
|j_|j`|j`dS)Nz
code.inputT)Zcreatezcode.sys.stdoutzcode.sys.stderrzcode.sys)�wraps�spec)rZ
addCleanup�close�
enter_contextrZpatch�infunc�stdout�stderrr�sys�sysmod�
excepthook�__excepthook__�ps1�ps2)r
�stackZprepatchrrrr	s
zTestInteractiveConsole.mock_syscCsLtd�|j_|j��|�|jjd�d|j_|j��|�|jjd�dS)N�Finishedz>>> z	custom1> )�EOFErrorr�side_effectr�interact�assertEqualrr)r
rrr�test_ps1"s

zTestInteractiveConsole.test_ps1cCsLtd�|j_|j��|�|jjd�d|j_|j��|�|jjd�dS)Nrz... z	custom2> )	rrrrrr rrr)r
rrr�test_ps2*s

zTestInteractiveConsole.test_ps2cCsRddtd�g|j_|j��x0t|jj�D]}dd�|d�kr*Pq*Wt	d��dS)Nz	'antioch'�rZantioch�zno console stdout)
rrrrr�listr�method_calls�join�AssertionError)r
�callrrr�test_console_stderr2s
z*TestInteractiveConsole.test_console_stderrcCsLdtd�g|j_|j��x,|jjD]}dd�|d�kr$Pq$Wtd��dS)NZ	undefinedr�	NameErrorr#r$zNo syntax error from console)	rrrrrrr&r'r()r
r)rrr�test_syntax_error;s
z(TestInteractiveConsole.test_syntax_errorcCs:dtd�g|j_t��}||j_|j��|�	|j
�dS)Nzraise ValueError('')r)rrrrZMockrrrrZ
assertTrueZcalled)r
�hookrrr�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#�)
rrrrrr �lenrr&�
reset_mock)r
Zbanner_callrrr�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#)r/r2r$z"now exiting InteractiveConsole...
r1)r/Zexitmsgu	bye! ζж�
)
rrrrrr r3rr&r4)r
Zerr_msg�expected�messagerrr�
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)rrr�	<genexpr>zsz7TestInteractiveConsole.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
        )
rrrrrr'rr&r�assertIn)r
�outputr7rrr�
test_cause_tbvs
z$TestInteractiveConsole.test_cause_tbcCsJdtd�g|j_|j��d�dd�|jjD��}td�}|�	||�dS)Nztry: ham
except: eggs
rr#css|]}d�|d�VqdS)r#r$N)r')r:r)rrrr;�sz9TestInteractiveConsole.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
        )
rrrrrr'rr&rr<)r
r=r7rrr�test_context_tb�s

z&TestInteractiveConsole.test_context_tbN)�__name__�
__module__�__qualname__r
r	r!r"r*r,r.r5r9r>r?rrrrrs		r�__main__)rZunittest�textwrapr�
contextlibrrZtestr�
import_modulerZTestCaserr@�mainrrrr�<module>s