HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_code_module.cpython-312.opt-2.pyc
�

h�e#����	ddlZddlZddlmZddlmZddlmZddlmZejd�Z
Gd�dej�Ze
d	k(rej�yy)
�N)�dedent)�	ExitStack)�mock)�
import_helper�codec�N�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�TestInteractiveConsolec�V�tj�|_|j�y)N)r�InteractiveConsole�console�mock_sys��selfs �</opt/alt/python312/lib64/python3.12/test/test_code_module.py�setUpzTestInteractiveConsole.setUps���.�.�0����
�
��c��	t�}|j|j�|jt	j
dd���|_|jt	j
d��|_|jt	j
d��|_t	j
dtjtj��}|j|�|_tjtjur%|jj|j_|j`|j`y)Nz
code.inputT)�createzcode.sys.stdoutzcode.sys.stderrzcode.sys)�wraps�spec)r�
addCleanup�close�
enter_contextr�patch�infunc�stdout�stderrr�sys�sysmod�
excepthook�__excepthook__�ps1�ps2)r�stack�prepatchs   rr
zTestInteractiveConsole.mock_syss���8����������$��)�)�$�*�*�\�15�+7�8����)�)�$�*�*�5F�*G�H����)�)�$�*�*�5F�*G�H����:�:�j����t�x�x�H���)�)�(�3����>�>�S�/�/�/�%)�[�[�%?�%?�D�K�K�"��K�K�O��K�K�Orc�Z�td�|j_|jj	�|j|jjd�d|j_|jj	�|j|jjd�y)N�Finishedz>>> z	custom1> )�EOFErrorr�side_effectr�interact�assertEqualrr"rs r�test_ps1zTestInteractiveConsole.test_ps1#�n��"*�:�"6�������������������&�1�%�������������������+�6rc�Z�td�|j_|jj	�|j|jjd�d|j_|jj	�|j|jjd�y)Nr'z... z	custom2> )	r(rr)rr*r+rr#r"rs r�test_ps2zTestInteractiveConsole.test_ps2+r-rc��ddtd�g|j_|jj	�t|jj�D]}ddj|d�vs�ytd��)Nz	'antioch'�r'�antioch�zno console stdout)
r(rr)rr*�listr�method_calls�join�AssertionError�r�calls  r�test_console_stderrz*TestInteractiveConsole.test_console_stderr3sn��#.��H�Z�4H�"I���������������1�1�2�	6�D��B�G�G�D��G�,�,��	6�!�!4�5�5rc���dtd�g|j_|jj	�|j
jD]}ddj|d�vs�ytd��)N�	undefinedr'�	NameErrorr1r3zNo syntax error from console)	r(rr)rr*rr5r6r7r8s  r�test_syntax_errorz(TestInteractiveConsole.test_syntax_error<si��#.���0D�"E������������K�K�,�,�	A�D��b�g�g�d�1�g�.�.��	A�!�!?�@�@rc���dtd�g|j_tj�}||j
_|jj�|j|j�y)Nzraise ValueError('')r')r(rr)r�Mockrr rr*�
assertTrue�called)r�hooks  r�test_sysexcepthookz)TestInteractiveConsole.test_sysexcepthookEsR��#9�$,�Z�$8�#:������y�y�{��!%�����������������$rc�(�td�|j_|jj	d��|jt
|jj�d�|jjd}|j|ddig�|jj�td�|j_|jj	d��|jt
|jj�d	�y)
Nr'�Foo��banner�r�write)zFoo
r1��
r(rr)rr*r+�lenrr5�
reset_mock)r�banner_calls  r�test_bannerz"TestInteractiveConsole.test_bannerMs���"*�:�"6����������U��+�����T�[�[�5�5�6��:��k�k�.�.�q�1������w�
�B�&?�@�	
����� �"*�:�"6����������R��(�����T�[�[�5�5�6��:rc��td�|j_|jj	d��|jt
|jj�d�|jjd}d}|j|d|fig�|jj�td�|j_|jj	dd��|jt
|jj�d�|jj�d	}td�|j_|jj	d|��|jt
|jj�d�|jjd}|d
z}|j|d|fig�y)Nr'r1rGrKr3z"now exiting InteractiveConsole...
rJ)rH�exitmsgu	bye! ζж�
rL)r�err_msg�expected�messages    r�
test_exit_msgz$TestInteractiveConsole.test_exit_msg[sk��"*�:�"6����������R��(�����T�[�[�5�5�6��:��+�+�*�*�1�-��8������7�X�K��"<�=�	
����� �"*�:�"6����������R���4�����T�[�[�5�5�6��:�	
����� �K�	�#+�:�"6����������R���9�����T�[�[�5�5�6��:��+�+�*�*�1�-���T�>������7�X�K��"<�=rc��dtd�g|j_|jj	�djd�|jjD��}td�}|j||�y)Nz(raise ValueError('') from AttributeErrorr'r1c3�DK�|]}dj|d����y�w�r1r3N�r6��.0r9s  r�	<genexpr>z7TestInteractiveConsole.test_cause_tb.<locals>.<genexpr>{�����O�d�����a��)�O��� 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
        �
r(rr)rr*r6rr5r�assertIn�r�outputrUs   r�
test_cause_tbz$TestInteractiveConsole.test_cause_tbwsh��#M�$,�Z�$8�#:��������������O�d�k�k�6N�6N�O�O����
��	
�
�
�h��'rc��dtd�g|j_|jj	�djd�|jjD��}td�}|j||�y)Nztry: ham
except: eggs
r'r1c3�DK�|]}dj|d����y�wrZr[r\s  rr^z9TestInteractiveConsole.test_context_tb.<locals>.<genexpr>�r_r`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
        rarcs   r�test_context_tbz&TestInteractiveConsole.test_context_tb�sh��#=�$,�Z�$8�#:��������������O�d�k�k�6N�6N�O�O���
�

��	
�
�
�h��'rN)�__name__�
__module__�__qualname__rr
r,r/r:r>rDrPrWrerh�rrr	r	
s:���� 7�7�6�A�%�;�>�8(� (rr	�__main__)r�unittest�textwrapr�
contextlibrr�test.supportr�
import_moduler�TestCaser	ri�mainrlrr�<module>rus]��E�
��� ��&�#�}�"�"�6�*��J(�X�.�.�J(�Z�z���H�M�M�O�r