Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_code_module.cpython-312.pyc

�

'Μg�2����dZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
e
jd�ZGd�d	ej�Zed
k(rej �yy)zCTest InteractiveConsole and InteractiveInterpreter from code module�N)�dedent)�	ExitStack)�mock)�
import_helper�codec�|�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TestInteractiveConsoleNc�V�tj�|_|j�y�N)r�InteractiveConsole�console�mock_sys��selfs �2/usr/local/lib/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)	z.Mock system environment for InteractiveConsolez
code.inputT)�createzcode.sys.stdoutzcode.sys.stderrzcode.sys)�wraps�specN)r�
addCleanup�close�
enter_contextr�patch�infunc�stdout�stderrr�sys�sysmod�
excepthook�__excepthook__�ps1�ps2)r�stack�prepatchs   rrzTestInteractiveConsole.mock_syss������������$��)�)�$�*�*�\�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�assertEqualr r#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,r r$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_stderr5si��#.��H�Z�4H�"I���������������1�1�2�D��B�G�G�D��G�,�,��3�!�!4�5�5rc�<�dddtd�g|j_|jj	�djd�|jjD��}||jd�d}|d|jd�}|j|j�ddgd	��|j|jjt�|jt|jj �t�|j#|jj$�|j#|jj j&�|j|jj(|jj �y)
N�def f():�	    x = ?r2r(c3�DK�|]}dj|d����y�w�r2r4N�r7��.0r9s  r�	<genexpr>z;TestInteractiveConsole.test_syntax_error.<locals>.<genexpr>D� ����O�6N�d�����a��)�6N��� �(InteractiveConsole)�
now exitingr4)z  File "<console>", line 2r=z	        ^zSyntaxError: invalid syntax)r)rr*r
r+r7rr6�indexr,�
splitlines�assertIsr �	last_type�SyntaxError�type�
last_value�assertIsNone�last_traceback�
__traceback__�last_exc�r�outputs  r�test_syntax_errorz(TestInteractiveConsole.test_syntax_error>s2��#-�#.�#%�$,�Z�$8�#:�����	
���������O�d�k�k�6N�6N�O�O������%;�<�=�>���6����o�6�7������*�*�,�Q�R�0�3+�	,�
	
�
�
�d�k�k�+�+�[�9��
�
�d�4�;�;�1�1�2�K�@����$�+�+�4�4�5����$�+�+�0�0�>�>�?��
�
�d�k�k�*�*�D�K�K�,B�,B�Crc�8�dtd�g|j_|jj	�djd�|jjD��}||jd�d}|d|jd�}|j|j�ddgd��|j|jjt�|jt|jj �t�|j#|jj$�|j#|jj j&�|j|jj(|jj �y)	N�  1r(r2c3�DK�|]}dj|d����y�wr?r@rAs  rrCz@TestInteractiveConsole.test_indentation_error.<locals>.<genexpr>UrDrErFrGr4)z  File "<console>", line 1z    1z#IndentationError: unexpected indent)r)rr*r
r+r7rr6rHr,rIrJr rK�IndentationErrorrMrNrOrPrQrRrSs  r�test_indentation_errorz-TestInteractiveConsole.test_indentation_errorRs)��#(�(�:�*>�"?��������������O�d�k�k�6N�6N�O�O������%;�<�=�>���6����o�6�7������*�*�,�Q�R�0�33�	4�	
�
�
�d�k�k�+�+�-=�>��
�
�d�4�;�;�1�1�2�4D�E����$�+�+�4�4�5����$�+�+�0�0�>�>�?��
�
�d�k�k�*�*�D�K�K�,B�,B�Crc�6�dtd�g|j_|jj	�djd�|jjD��}||jd�d}||jd�dzd}|j|jd�|�|j|jjt�|jt|jj �t�|j#|jj$�|j#|jj j&�|j|jj(|jj �y)	Nu'�'r(r2c3�DK�|]}dj|d����y�wr?r@rAs  rrCz<TestInteractiveConsole.test_unicode_error.<locals>.<genexpr>erDrErF�
r4zUnicodeEncodeError: )r)rr*r
r+r7rr6rH�
assertTrue�
startswithrJr rK�UnicodeEncodeErrorrMrNrOrPrQrRrSs  r�test_unicode_errorz)TestInteractiveConsole.test_unicode_errorbs!��#-�x�
�/C�"D��������������O�d�k�k�6N�6N�O�O������%;�<�=�>������T�*�Q�.�/�0������)�)�*@�A�6�J��
�
�d�k�k�+�+�-?�@��
�
�d�4�;�;�1�1�2�4F�G����$�+�+�4�4�5����$�+�+�0�0�>�>�?��
�
�d�k�k�*�*�D�K�K�,B�,B�Crc��ddddtd�g|j_tj�}||j
_|jj�|j�|j|j
j|j
j|j
j�|j|j
jt�|jt!|j
j�t�|j|j
j|j
jj"�|j|j
j$|j
j�|j't)j*|j
j$�gd��y)Nr<z    raise ValueError('BOOM!')r2zf()r()z#Traceback (most recent call last):
z(  File "<console>", line 1, in <module>
z!  File "<console>", line 2, in f
zValueError: BOOM!
)r)rr*r�Mockr r!r
r+�
assert_called�assert_called_withrKrNrPrJ�
ValueErrorrMrQrRr,�	traceback�format_exception�r�hooks  r�test_sysexcepthookz)TestInteractiveConsole.test_sysexcepthookos9��#-�#B�#%�#(�$,�Z�$8�	#:�����
�y�y�{��!%��������������������� 5� 5� $��� 6� 6� $��� :� :�	<�	
�
�
�d�k�k�+�+�Z�8��
�
�d�4�;�;�1�1�2�J�?��
�
�d�k�k�0�0�$�+�+�2H�2H�2V�2V�W��
�
�d�k�k�*�*�D�K�K�,B�,B�C�����3�3�D�K�K�4H�4H�I�L#�	$rc���dddtd�g|j_tj�}||j
_|jj�|j�|j|j
j|j
j|j
j�|j|j
jt�|jt!|j
j�t�|j#|j
j�|j#|j
jj$�|j|j
j&|j
j�|j)t+j,|j
j&�gd��y)Nr<r=r2r()z  File "<console>", line 2
z
    x = ?
z
        ^
zSyntaxError: invalid syntax
)r)rr*rrcr r!r
r+rdrerKrNrPrJrLrMrOrQrRr,rgrhris  r�test_sysexcepthook_syntax_errorz6TestInteractiveConsole.test_sysexcepthook_syntax_error�sD��#-�#.�#%�$,�Z�$8�#:������y�y�{��!%��������������������� 5� 5� $��� 6� 6� $��� :� :�	<�	
�
�
�d�k�k�+�+�[�9��
�
�d�4�;�;�1�1�2�K�@����$�+�+�4�4�5����$�+�+�0�0�>�>�?��
�
�d�k�k�*�*�D�K�K�,B�,B�C�����3�3�D�K�K�4H�4H�I�L-�	.rc���dtd�g|j_tj�}||j
_|jj�|j�|j|j
j|j
j|j
j�|j|j
jt�|jt!|j
j�t�|j#|j
j�|j#|j
jj$�|j|j
j&|j
j�|j)t+j,|j
j&�gd��y)NrWr()z  File "<console>", line 1
z    1
z$IndentationError: unexpected indent
)r)rr*rrcr r!r
r+rdrerKrNrPrJrYrMrOrQrRr,rgrhris  r�$test_sysexcepthook_indentation_errorz;TestInteractiveConsole.test_sysexcepthook_indentation_error�s;��#(�(�:�*>�"?������y�y�{��!%��������������������� 5� 5� $��� 6� 6� $��� :� :�	<�	
�
�
�d�k�k�+�+�-=�>��
�
�d�4�;�;�1�1�2�4D�E����$�+�+�4�4�5����$�+�+�0�0�>�>�?��
�
�d�k�k�*�*�D�K�K�,B�,B�C�����3�3�D�K�K�4H�4H�I�L5�	6rc���dddtd�g|j_d|j_|j
j
�|jddig|jjd�d	jd
�|jjD��}|jd|�|j|jd�d�|jd
|�|jd|�y)N�1/0�a = 123�print(a)r(r4�write��123rr2c3�LK�|]}|ddk(s�|jd���y�w�rrtN��argsrAs  rrCzWTestInteractiveConsole.test_sysexcepthook_crashing_doesnt_close_repl.<locals>.<genexpr>��(����`�1I��T�RS�W�X_�M_��	�	�!��1I���
$�$�Error in sys.excepthook:z'int' object is not callable�Original exception was:�division by zero�r)rr*r r!r
r+r,rr6r7r�assertIn�count)r�errors  r�-test_sysexcepthook_crashing_doesnt_close_replzDTestInteractiveConsole.test_sysexcepthook_crashing_doesnt_close_repl�s���#(�)�Z��*�AU�"V�����!"��������������'�9�b�1�4�;�;�3K�3K�A�3N�O����`����1I�1I�`�`���
�
�0�%�8�������%C�D�a�H��
�
�/��7��
�
�(�%�0rc���dddtd�g|j_d��fd�}||j_|j
j
�|jddig|jjd	�d
jd�|jjD��}|jd|�|j|jd�d
�|jd|�|jd|�y)Nrqrrrsr(znot so fastc���t���r)�
BaseException)rz�kwargs�ss  �r�
raise_basezSTestInteractiveConsole.test_sysexcepthook_raising_BaseException.<locals>.raise_base�s�����"�"rrtrurr2c3�LK�|]}|ddk(s�|jd���y�wrxryrAs  rrCzRTestInteractiveConsole.test_sysexcepthook_raising_BaseException.<locals>.<genexpr>�r{r|r}r4r~rr�)rr�r�r�s   @r�(test_sysexcepthook_raising_BaseExceptionz?TestInteractiveConsole.test_sysexcepthook_raising_BaseException�s����#(�)�Z��*�AU�"V�������	#�!+��������������'�9�b�1�4�;�;�3K�3K�A�3N�O����`����1I�1I�`�`���
�
�0�%�8�������]�3�Q�7��
�
�/��7��
�
�(�%�0rc���dg|j_d�}||j_|j	t
�5|jj�ddd�y#1swYyxYw)Nrqc��t�r)�
SystemExit)rzr�s  rr�z]TestInteractiveConsole.test_sysexcepthook_raising_SystemExit_gets_through.<locals>.raise_base�s���r)rr*r r!�assertRaisesr�r
r+)rr�s  r�2test_sysexcepthook_raising_SystemExit_gets_throughzITestInteractiveConsole.test_sysexcepthook_raising_SystemExit_gets_through�sK��#(�'�����	�!+�����
�
�
�z�
*��L�L�!�!�#�+�
*�
*�s�A � A)c�(�td�|j_|jj	d��|jt
|jj�d�|jjd}|j|ddig�|jj�td�|j_|jj	d��|jt
|jj�d	�y)
Nr(�Foo��banner�rrt)zFoo
r2��
r)rr*r
r+r,�lenrr6�
reset_mock)r�banner_calls  r�test_bannerz"TestInteractiveConsole.test_banner�s���"*�:�"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(r2r�r�r4z"now exiting InteractiveConsole...
rt)r��exitmsgu	bye! ζжr]r�)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||�|j|jjt�|jt|jj�t�|j|jj |jjj"�|j%|jj �|j|jj&|jj�y)Nz(raise ValueError('') from AttributeErrorr(r2c3�DK�|]}dj|d����y�wr?r@rAs  rrCz7TestInteractiveConsole.test_cause_tb.<locals>.<genexpr>�rDrEz�
        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+r7rr6rr�rJr rKrfrMrNrPrQ�assertIsNotNonerR�rrTr�s   r�
test_cause_tbz$TestInteractiveConsole.test_cause_tb�s���#M�$,�Z�$8�#:��������������O�d�k�k�6N�6N�O�O����
��	
�
�
�h��'��
�
�d�k�k�+�+�Z�8��
�
�d�4�;�;�1�1�2�J�?��
�
�d�k�k�0�0�$�+�+�2H�2H�2V�2V�W����T�[�[�7�7�8��
�
�d�k�k�*�*�D�K�K�,B�,B�Crc��dtd�g|j_|jj	�djd�|jjD��}td�}|j||�|j|jjt�|jt|jj�t�|j|jj |jjj"�|j%|jj �|j|jj&|jj�y)Nztry: ham
except: eggs
r(r2c3�DK�|]}dj|d����y�wr?r@rAs  rrCz9TestInteractiveConsole.test_context_tb.<locals>.<genexpr>rDrEah
        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
        )r)rr*r
r+r7rr6rr�rJr rK�	NameErrorrMrNrPrQr�rRr�s   r�test_context_tbz&TestInteractiveConsole.test_context_tbs���#=�$,�Z�$8�#:��������������O�d�k�k�6N�6N�O�O���
�

��	
�
�
�h��'��
�
�d�k�k�+�+�Y�7��
�
�d�4�;�;�1�1�2�I�>��
�
�d�k�k�0�0�$�+�+�2H�2H�2V�2V�W����T�[�[�7�7�8��
�
�d�k�k�*�*�D�K�K�,B�,B�Cr)�__name__�
__module__�__qualname__�maxDiffrrr-r0r:rUrZrarkrmror�r�r�r�r�r�r��rrr	r	sf���G��� 7�7�6�D�(D� D�$�..�.6�&	1�1�$�;�>�8D�*Drr	�__main__)�__doc__rrg�unittest�textwrapr�
contextlibrr�test.supportr�
import_moduler�TestCaser	r��mainr�rr�<module>r�sb��E�
���� ��&�#�}�"�"�6�*��WD�X�.�.�WD�t�z���H�M�M�O�r

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