Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_repl.cpython-311.pyc
�

�Ke����dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZe	sej
d���ejejd�d�Zd	�ZGd
�dej��ZGd�d
ej��Zedkrej��dSdS)z!Test the interactive interpreter.�N)�dedent)�cpython_only�has_subprocess_support�SuppressCrashReport)�kill_pythonztest module requires subprocess)�stdout�stderrc	��tj�tj�tj��d��}|ddg}|�|��|�dttj	����}d|d<tj|ftjdtj||d�|��S)	z�Run the Python REPL with the given arguments.

    kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
    object.
    z<stdin>z-Ez-i�env�vt100�TERMT)�
executable�text�stdinrr	)
�os�path�join�dirname�sysr�extend�
setdefault�dict�environ�
subprocess�Popen�PIPE)rr	�args�kw�stdin_fname�cmd_liners       �8/usr/local/apps/python3/lib/python3.11/test/test_repl.py�
spawn_replr"s����'�,�,�r�w���s�~�>�>�	�J�J�K��T�4�(�H��O�O�D����
�-�-��t�B�J�/�/�
0�
0�C��C��K���H�"�'*�~�!%�",�/�#)�&�	"�"�
!�"�"�"�c��t��}|j�|��t|��}|jdkrtd���|S)z�Spawn a new Python interpreter, pass the given
    input source code from the stdin and return the
    result back. If the interpreter exits non-zero, it
    raises a ValueError.rzProcess didn't exit properly.)r"r�writer�
returncode�
ValueError)�source�process�outputs   r!�run_on_interactive_moder+,sR���l�l�G��M�������
��
!�
!�F���Q����8�9�9�9��Mr#c�@�eZdZed���Zed���Zd�ZdS)�TestInteractiveInterpreterc�D�d}t|��}t��}t��5|j�|��ddd��n#1swxYwYt|��}|�d|��|�|jd��dS)Nz�
            import sys, _testcapi
            1/0
            print('After the exception.')
            _testcapi.set_nomemory(0)
            sys.exit(0)
        zAfter the exception.)��x)rr"rrr%r�assertInr&��self�
user_input�pr*s    r!�test_no_memoryz)TestInteractiveInterpreter.test_no_memory=s���
�
��J�'�'�
��L�L��
 �
"�
"�	&�	&�
�G�M�M�*�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&��Q�����
�
�,�f�5�5�5��
�
�a�l�H�-�-�-�-�-s�A�A�Ac���d}t|��}t��}|j�|��t	|��}|�|jd��dS)Na        x = """<?xml version="1.0" encoding="iso-8859-1"?>
        <test>
            <Users>
                <fun25>
                    <limits>
                        <total>0KiB</total>
                        <kbps>0</kbps>
                        <rps>1.3</rps>
                        <connections>0</connections>
                    </limits>
                    <usages>
                        <total>16738211KiB</total>
                        <kbps>237.15</kbps>
                        <rps>1.3</rps>
                        <connections>0</connections>
                    </usages>
                    <time_to_refresh>never</time_to_refresh>
                    <limit_exceeded_URL>none</limit_exceeded_URL>
                </fun25>
            </Users>
        </test>"""
        r)rr"rr%r�assertEqualr&r2s    r!�test_multiline_string_parsingz8TestInteractiveInterpreter.test_multiline_string_parsingRs^���
�.�J�'�'�
��L�L��	��
�
�j�!�!�!��Q���������q�)�)�)�)�)r#c��td��}td��}td|��}|�|��d}|�|jd��|�d|��dS)NzY
            import os
            print("before close")
            os.close(0)
        zl
            from test.support import suppress_msvcrt_asserts
            suppress_msvcrt_asserts()
        z-crzbefore close)rr"�communicater8r&r1)r3r4�prepare_replr)r*s     r!�test_close_stdinz+TestInteractiveInterpreter.test_close_stdinss�����
�
�
�
��
�
���T�<�0�0���$�$�Z�0�0��3������+�Q�/�/�/��
�
�n�f�-�-�-�-�-r#N)�__name__�
__module__�__qualname__rr6r9r=�r#r!r-r-;sX�������.�.��\�.�(�*�*��\�*�@
.�
.�
.�
.�
.r#r-c��eZdZd�ZdS)�TestInteractiveModeSyntaxErrorsc��ttd����}|���dd�}gd�}|�||��dS)NzJ        def f():
            print(0)
            return yield 42
        ������)z    return yield 42z           ^^^^^zSyntaxError: invalid syntax)r+r�
splitlinesr8)r3r*�traceback_lines�expected_liness    r!�*test_interactive_syntax_error_correct_linezJTestInteractiveModeSyntaxErrors.test_interactive_syntax_error_correct_line�sm��(��1�*
�*
����!�+�+�-�-�b��e�4��
�
�
��
	
����.�9�9�9�9�9r#N)r>r?r@rJrAr#r!rCrC�s#������
:�
:�
:�
:�
:r#rC�__main__)�__doc__rr�unittestr�textwrapr�test.supportrrr�test.support.script_helperr�SkipTestr�STDOUTr"r+�TestCaser-rCr>�mainrAr#r!�<module>rUsO��'�'�
�
�
�
�	�	�	�	���������������R�R�R�R�R�R�R�R�R�R�2�2�2�2�2�2��?�
�(�
�=�
>�
>�>�(�_�Z�5F�"�"�"�"�"�8���E.�E.�E.�E.�E.��!2�E.�E.�E.�P:�:�:�:�:�h�&7�:�:�:�$�z����H�M�O�O�O�O�O��r#