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.10/test/__pycache__/test_code_module.cpython-310.opt-1.pyc
o

�i#�@sxdZddlZddlZddlmZddlmZddlmZddlm	Z	e	�
d�ZGdd	�d	ej�Z
ed
kr:e��dSdS)zCTest InteractiveConsole and InteractiveInterpreter from code module�N)�dedent)�	ExitStack)�mock)�
import_helper�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�2/usr/local/lib/python3.10/test/test_code_module.py�setUps
zTestInteractiveConsole.setUpcCs�t�}|�|j�|�tjddd��|_|�t�d��|_|�t�d��|_tjdt	j
t	j
d�}|�|�|_t
jt
j
urB|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#�

zTestInteractiveConsole.test_ps1cCsLtd�|j_|j��|�|jjd�d|j_|j��|�|jjd�dS)Nrz... z	custom2> )	rrrrr r!rrrr
rrr
�test_ps2+r#zTestInteractiveConsole.test_ps2cCsNddtd�g|j_|j��t|jj�D]}dd�|d�vr"dSqt	d��)Nz	'antioch'�rZantioch�zno console stdout)
rrrrr �listr�method_calls�join�AssertionError�r�callrrr
�test_console_stderr3s
�z*TestInteractiveConsole.test_console_stderrcCsHdtd�g|j_|j��|jjD]}dd�|d�vrdSqtd��)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_sysexcepthookEs�
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_bannerMs
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%r2r6r&z"now exiting InteractiveConsole...
r5)r3Zexitmsgu	bye! ζж�
r7)r�err_msg�expected�messagerrr
�
test_exit_msg[s&

�z$TestInteractiveConsole.test_exit_msgcC�Jdtd�g|j_|j��d�dd�|jjD��}td�}|�	||�dS)Nz(raise ValueError('') from AttributeErrorrr%cs��|]
}d�|d�VqdS�r%r&N�r)��.0r,rrr
�	<genexpr>{��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_tbws�
	z$TestInteractiveConsole.test_cause_tbcCr?)Nztry: ham
except: eggs
rr%csr@rArBrCrrr
rE�rFz9TestInteractiveConsole.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
        rGrHrrr
�test_context_tb�s�
z&TestInteractiveConsole.test_context_tbN)�__name__�
__module__�__qualname__rr	r"r$r-r/r1r9r>rJrKrrrr
r
s		r�__main__)�__doc__rZunittest�textwrapr�
contextlibrrZtest.supportr�
import_modulerZTestCaserrL�mainrrrr
�<module>s
�