B
    u9a                 @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
 ejejdddZG dd	 d	ejZed
kr~e  dS )    N)dedent)cpython_onlySuppressCrashReport)kill_python)stdoutstderrc             O   sf   t jt jtjd}|ddg}|| |dtt j	}d|d< t
j|ftjt
j| |d|S )Nz<stdin>z-Ez-ienvZvt100ZTERM)
executablestdinr   r   )ospathjoindirnamesysr	   extend
setdefaultdictenviron
subprocessPopenPIPE)r   r   argskwZstdin_fnameZcmd_liner    r   /usr/lib/python3.7/test_repl.py
spawn_repl   s    

r   c               @   s   e Zd Zedd ZdS )TestInteractiveInterpreterc          	   C   s^   d}t |}| }t }t  |j| W d Q R X t|}| d| | |jd d S )Nz
            import sys, _testcapi
            1/0
            print('After the exception.')
            _testcapi.set_nomemory(0)
            sys.exit(0)
        s   After the exception.)   x   )	r   encoder   r   r
   writer   ZassertIn
returncode)selfZ
user_inputpoutputr   r   r   test_no_memory'   s    z)TestInteractiveInterpreter.test_no_memoryN)__name__
__module____qualname__r   r%   r   r   r   r   r   %   s   r   __main__)r   r   Zunittestr   textwrapr   Ztest.supportr   r   Ztest.support.script_helperr   r   ZSTDOUTr   ZTestCaser   r&   mainr   r   r   r   <module>   s   