a ze@sddlZddlZddlZddlZddlmZddlmZmZddl m Z ej ej dddZ Gdd d ejZed kr~edS) N)dedent) cpython_onlySuppressCrashReport) kill_python)stdoutstderrcOshtjtjtjd}|ddg}|||dttj }d|d<t j |ftjdt j ||d|S) Nzz-Ez-ienvZvt100ZTERMT) executabletextstdinrr) ospathjoindirnamesysr extend setdefaultdictenviron subprocessPopenPIPE)rrargskwZ stdin_fnameZcmd_linerrB/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_repl.py spawn_repl s   rc@s,eZdZeddZeddZddZdS)TestInteractiveInterpretercCsjd}t|}t}t|j|Wdn1s:0Yt|}|d|||jddS)Nz import sys, _testcapi 1/0 print('After the exception.') _testcapi.set_nomemory(0) sys.exit(0) zAfter the exception.)x)rrrr writerassertIn returncodeself user_inputpoutputrrrtest_no_memory)s* z)TestInteractiveInterpreter.test_no_memorycCs8d}t|}t}|j|t|}||jddS)Na x = """ 0KiB 0 1.3 0 16738211KiB 237.15 1.3 0 never none """ r)rrr r r assertEqualr"r#rrrtest_multiline_string_parsing>s  z8TestInteractiveInterpreter.test_multiline_string_parsingcCsFtd}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 communicater)r"r!)r$r%Z prepare_replprocessr'rrrtest_close_stdin_s  z+TestInteractiveInterpreter.test_close_stdinN)__name__ __module__ __qualname__rr(r*r-rrrrr's   r__main__)rr ZunittestrtextwraprZ test.supportrrZtest.support.script_helperrrSTDOUTrZTestCaserr.mainrrrrs  H