+
    Bi                        ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIHtHtHtHt ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHt ^ RIHtHt ^R	IH t H!t!H"t"H#t#H$t$H%t%H&t& ^ R
I'H(t( ^ RI)H*t*H+t+ ^ RI,H-t-H.t.H/t/ ^ RI,H%t0  ^ RI1t1 ! R R]4      t3 ! R R]4      t4 ! R R]4      t5 ! R R]!]4      t6 ! R R]4      t7 ! R R]4      t8 ! R R]4      t9]! ]1R4       ! R R]34      4       t:]! ]1R4      ]! ]Pv                  Py                  R4      ;'       g    R R 8H  R!4       ! R" R#]34      4       4       t=R#   ]2 d    Rt1 Li ; i)$    N
ModuleInfo)TestCase
skipUnlessskipIfSkipTest)patch)force_not_colorizedmake_clean_envPy_DEBUG)has_subprocess_supportSHORT_TIMEOUT
STDLIB_DIR)import_module)EnvironmentVarGuardunlink)FakeConsoleScreenEqualMixinhandle_all_eventshandle_events_narrow_console
more_linesmultiline_inputcode_to_events)Event)ImportParserModuleCompleter)ReadlineAlikeReaderReadlineConfig_ReadlineWrapper)r   c            	       b   a  ] tR t^(t o R tRRRRRRRR]/V 3R lR	 llltV 3R
 lR ltRtV t	R# )ReplTestCasec                4    \         '       g   \        R 4      hR# )ztest module requires subprocessN)r   r   selfs   &3/usr/lib/python3.14/test/test_pyrepl/test_pyrepl.pysetUpReplTestCase.setUp)   s    %%<== &    Ncmdline_argscwdskipFtimeoutc                   < V ^8  d   QhRS[ S[S[ ,          ,          RS[R,          RS[S[ ,          R,          RS[ R,          RS[RS[RS[S[ S[3,          /# 	   
repl_inputenvNr)   r*   r+   r,   returnstrlistdictboolfloattupleint)format__classdict__s   "r%   __annotate__ReplTestCase.__annotate__-   sr     # #$s)O# D[#
 3i$&# 4Z# # # 
sCx#r(   c          	         R pVf$   \         P                  ! RR7      pVP                  p V P                  VVVVVVR7      Ve   VP	                  4        # #   Te   TP	                  4        i i ; i)NT)ignore_cleanup_errors)r1   r)   r*   r+   r,   )tempfileTemporaryDirectoryname	_run_replcleanup)r$   r0   r1   r)   r*   r+   r,   temp_dirs   &&&$$$$ r%   run_replReplTestCase.run_repl-   s     ;22NH--C	#>>) "  #  " $x#  " $s   A A.c                   < V ^8  d   QhRS[ S[S[ ,          ,          RS[R,          RS[S[ ,          R,          RS[ RS[RS[RS[S[ S[3,          /# r.   r3   )r;   r<   s   "r%   r=   r>   H   sw     E! E!$s)OE! D[	E!
 3i$&E! E! E! E! 
sCxE!r(   c                  \         P                  ! 4       w  rx\        P                  R R.p	Vf   V	P	                  R4       M*RV9  d$   \
        P                  P                  VR4      VR&   Ve   V	P                  V4        ^ RI	p
V
P                  V4      p^ V^,          V
P                  &   ^ V^,          V
P                  &   V
P                  WP                  V4       \         P"                  ! T	TTTTRRV'       d   TM\
        P$                  R7      p\
        P&                  ! V4       \)        V\*        4      '       d   RP                  V4      R,           p\
        P,                  ! WqP/                  R	4      4       . p\0        P0                  ! V.. . V4      ^ ,          '       dE    \
        P2                  ! VR
4      P5                  R	4      pV'       g   Mo TP	                  T4       Kk  \
        P&                  ! V4       VP9                  4        VP;                  VR7       V P=                  RRP                  V4       24       \
        P&                  ! V4        VP;                  VR7      pRP                  V4      pV'       d   RV9   d   V PA                  R4       W3#   \         d     ELi ; i  \6         d     K}  i ; i  \         P>                   d$    TP9                  4        TP;                  4       p Li ; i)z-iz-uNz-IPYTHON_HISTORYz.regrtest_historyT)stdinstdoutstderrr*   text	close_fdsr1   
utf-8i   )r,   z'Timeout while waiting for output, got:  zcan't use pyreplzpyrepl not available)!ptyopenptysys
executableappendospathjoinextendtermios	tcgetattrVREPRINTVINTR	tcsetattrTCSANOWModuleNotFoundError
subprocessPopenenvironclose
isinstancer5   writeencodeselectreaddecodeOSErrorkillwaitfailTimeoutExpiredskipTest)r$   r0   r1   r)   r*   r+   r,   	master_fdslave_fdcmdr]   	term_attrprocessoutputdata	exit_codes   &&$$$$$         r%   rD   ReplTestCase._run_replH   so    "kkm	~~tT*;JJtS($&GGLL6I$JC !#JJ|$	D  ))(3I-.IaL))**+IaL'hC""

	
 	j$'':.5J
--g67mmYKR9!<<wwy$/66w?  MM$HHYLLNLLL)II??PQR
	'W5I &&0MM01  _ # 		:   (( 	'LLNI	's6   J" '-J4 K "J10J14KK5K>=K> N)
__name__
__module____qualname____firstlineno__r&   r   rG   rD   __static_attributes____classdictcell__r<   s   @r%   r!   r!   (   sH     >#
 *.# # # '# #6E! E!r(   r!   c                      a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tRtV tR# )TestCursorPositionc                L    \        V4      p\        R R7      p\        W#R7      pV# Nreadline_completerconsoleconfigr   r   r   r$   eventsr   r   readers   &&   r%   prepare_reader!TestCursorPosition.prepare_reader   %    f%48$WDr(   c           
         R p\         P                  ! \        V4      \        RR\	        R4      R7      .4      p\        V4      w  r4V P                  VP                  R4       VP                  P                  ^ ^4       R# )def f():
  ...
keyup   OAevtrz   rawN)r      
	itertoolschainr   r   	bytearrayr   assertEqualcxymove_cursorassert_called_once_withr$   coder   r   r   s   &    r%   test_up_arrow_simple'TestCursorPosition.test_up_arrow_simple   sr     	
 4 %d	)0DE
 ,F3V,33Aq9r(   c           
         R p\         P                  ! \        V4      \        RR\	        R4      R7      .4      p\        V4      w  r4V P                  VP                  R4       VP                  P                  ^ ^4       R# )r   r   down   OBr   N)r   r/   r   r   s   &    r%   test_down_arrow_end_of_input/TestCursorPosition.test_down_arrow_end_of_input   sr     	
 4 %f)I2FG
 ,F3V,33Aq9r(   c           
         \         P                  ! \        R 4      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VP                  R4       VP                  P                  ^^ 4       R# )11+11r   left   ODr   N)   r   r   r$   r   r   r   s   &   r%   test_left_arrow_simple)TestCursorPosition.test_left_arrow_simple   sf    7#%f)I2FG
 ,F3V,33Aq9r(   c           
         \         P                  ! \        R 4      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VP                  R4       VP                  P                  ^^ 4       R# )r   r   right   OCr   N)   r   r   r   s   &   r%   test_right_arrow_end_of_line/TestCursorPosition.test_right_arrow_end_of_line   sf    7#%g9Y3GH
 ,F3V,33Aq9r(   c                    \         P                  ! \        R 4      4      p\        V4      w  r#V P	                  VP
                  ^4       V P	                  VP                  R4       R# )kN)r   r   r   r   r   r   r   posr   r$   r   r   _s   &   r%   %test_cursor_position_simple_character8TestCursorPosition.test_cursor_position_simple_character   sK    !45%f-	Q' 	V,r(   c                    \         P                  ! \        R 4      4      p\        V4      w  r#V P	                  VP
                  ^4       V P	                  VP                  R4       R# )   樂Nr/   r   r   r   s   &   r%   +test_cursor_position_double_width_character>TestCursorPosition.test_cursor_position_double_width_character   sK    !67%f-	Q' 	V,r(   c           
         \         P                  ! \        R 4      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VP                  ^ 4       V P                  VP                  R4       R# )r   r   r   r   r   N)r   r   	r   r   r   r   r   r   r   r   r   r   s   &   r%   5test_cursor_position_double_width_character_move_leftHTestCursorPosition.test_cursor_position_double_width_character_move_left   sd    5!%f)I2FG
 &f-	Q'V,r(   c                (   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VP                  ^4       V P                  VP                  R4       R# )	r   r   r   r   r   r   r   Nr   r   r   s   &   r%   ;test_cursor_position_double_width_character_move_left_rightNTestCursorPosition.test_cursor_position_double_width_character_move_left_right   sw    5!%f)I2FG%g9Y3GH
 &f-	Q' 	V,r(   c           
     2   R pV R2p\         P                  ! \        V4      \        RR\	        R4      R7      .4      p\        V4      w  rEV P                  VP                  \        V4      4       V P                  VP                  \        V4      ^ 34       R# )for _ in _:    
  ' 可口可乐; 可口可樂'r   r   r   r   N
r   r   r   r   r   r   r   r   lenr   r$   for_loopr   r   r   r   s   &     r%   4test_cursor_position_double_width_characters_move_upGTestCursorPosition.test_cursor_position_double_width_characters_move_up   s      Z . . 	 4 %d	)0DE
 &f-	 	S]3c(mQ%78r(   c                b   R pV R2p\         P                  ! \        V4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R	4      R7      .4      p\        V4      w  rEV P                  VP                  ^4       V P                  VP                  R4       R
# )r   r   r   r   r   r   r   r   r   r   N)
   r   r   r   s   &     r%   9test_cursor_position_double_width_characters_move_up_downLTestCursorPosition.test_cursor_position_double_width_characters_move_up_down  s      Z . . 	 4 %d	)0DE%f)I2FG%f)I2FG
 &f-	
 	R(W-r(   c                T   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VP                  ^
4       V P                  VP                  R4       R# )u   ' 可口可乐; 可口可樂'r   r   r   r   N)   r   r   r   s   &   r%   ?test_cursor_position_multiple_double_width_characters_move_leftRTestCursorPosition.test_cursor_position_multiple_double_width_characters_move_left2  s    :;%f)I2FG%f)I2FG%f)I2FG
 &f-	R( 	W-r(   c                   R pRpV RV R2p\         P                  ! \        V4      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      p\        V4      w  rVV P                  VP                  \        V4      \        V4      ,           ^,           4       V P                  VP                  \        V4      ^34       R# )	r   z  hellorQ   z

  h
  helr   r   r   r   Nr   )r$   
first_linesecond_liner   r   r   r   s   &      r%   #test_cursor_position_move_up_to_eol6TestCursorPosition.test_cursor_position_move_up_to_eolC  s    "
 l"m  	 4 %d	)0DE%d	)0DE
 &f-	 	JJJ#k*::Q>	
 	c+&6%:;r(   c                   R pRV 2p\         P                  ! \        V4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      p\        V4      w  rEV P                  VP                  \        V4      4       V P                  VP                  \        V4      ^34       R# )	z  helzfor _ in _:
  hello
  h
r   r   r   r   r   r   Nr   )r$   	last_liner   r   r   r   s   &     r%   %test_cursor_position_move_down_to_eol8TestCursorPosition.test_cursor_position_move_down_to_eold  s    	 [ 	 4 %d	)0DE%d	)0DE%f)I2FG%f)I2FG	
 &f-	 	SY/c)na%89r(   c                <   R p\         P                  ! \        V4      ^\        RR\	        R4      R7      .,          \        RR\	        R4      R7      .4      p\        V4      w  r4V P                  VP                  ^4       V P                  VP                  R4       R# )	uI   def foo():
  x = '可口可乐; 可口可樂'
  y = 'abckdfjskldfjslkdjf'r   r   r   r   r   r   N)   r   r   r$   r   r   r   r   s   &    r%   1test_cursor_position_multiple_mixed_lines_move_upDTestCursorPosition.test_cursor_position_multiple_mixed_lines_move_up  s    * 	 4 %EIi4HIJJu4Yy-ABC
 &f-	 	R(W-r(   c           
         R p\         P                  ! \        V4      \        RR\	        R4      R7      .4      p\        V4      w  r4V P                  VP                  ^
4       V P                  VP                  R4       R# )zdef foo():
  hellor   r   r   r   N)r   r   )	r   r   r   r   r   r   r   r   r   r   s   &    r%   +test_cursor_position_after_wrap_and_move_up>TestCursorPosition.test_cursor_position_after_wrap_and_move_up  sr     	 4 %d	)0DE
 18	 	R(V,r(   r}   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @r%   r   r      s\     :$:$
:
:--
--9..6."<B:@.4- -r(   r   c                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )TestPyReplAutoindenti  c                L    \        V4      p\        R R7      p\        W#R7      pV# r   r   r   s   &&   r%   r   #TestPyReplAutoindent.prepare_reader  r   r(   c                ~    R pRp\        V4      pV P                  V4      p\        V4      pV P                  WR4       R# )zdef f():
pass

zdef f():
    pass
    Nr   r   r   r   r$   
input_codeoutput_coder   r   ry   s   &     r%   test_auto_indent_default-TestPyReplAutoindent.test_auto_indent_default  sJ     	 	  
+$$V, (-r(   c           
         \         P                  ! \        R 4      \        RR\	        R4      R7      .\        R4      4      pRpV P                  V4      p\        V4      pV P                  WB4       R# )	def f():
r   	backspace   r     pass
pass

zdef f():
  pass
  pass
  Nr   r   r   r   r   r   r   r   r$   r   r   r   ry   s   &    r%   test_auto_indent_continuation2TestPyReplAutoindent.test_auto_indent_continuation  su     <( %ky7IJ 

 	 $$V, (-r(   c           
        \         P                  ! \        R 4      \        RR\	        R4      R7      .\        R4      \        R4      4      pRpV P                  V4      p\        V4      p\        V4      pV P                  WR4       R# )	r   r   r  r  r   r  zdef g():
pass

zdef g():
  pass
  Nr  )r$   r   r   r   output1output2s   &     r%   test_auto_indent_prev_block0TestPyReplAutoindent.test_auto_indent_prev_block  s     <( %ky7IJ  
" 	 $$V,!&)!&).r(   c                   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .\        R	4      \        RR
\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pRpV P                  V4      p\        V4      pV P                  WB4       R# )zdef f():
passr   r   r   r   s   O5rQ      
passr   r   zdef f():
    pass
    pass
    Nr  r  s   &    r%   test_auto_indent_multiline/TestPyReplAutoindent.test_auto_indent_multiline  s     %d	)0DE%f)I2FG%d	%0@A 
 %f)I2FG%f)I2FG%d	%0@A%d	%0@A
4 	 $$V, (-r(   c                z    \        R 4      pRpV P                  V4      p\        V4      pV P                  WB4       R# )zdef f():  # foo
pass

zdef f():  # foo
    pass
    Nr   r  s   &    r%   test_auto_indent_with_comment2TestPyReplAutoindent.test_auto_indent_with_comment2  E    
 	 $$V, (-r(   c                z    \        R 4      pRpV P                  V4      p\        V4      pV P                  WB4       R# )zdef f():  ## foo
pass

zdef f():  ## foo
    pass
    Nr   r  s   &    r%   "test_auto_indent_with_multicomment7TestPyReplAutoindent.test_auto_indent_with_multicommentD  r  r(   c                z    \        R 4      pRpV P                  V4      p\        V4      pV P                  WB4       R# )z	pass  #:
zpass  #:Nr   r  s   &    r%    test_auto_indent_ignore_comments5TestPyReplAutoindent.test_auto_indent_ignore_commentsV  sC    

  	
 $$V, (-r(   r}   N)r   r   r   r   r   r   r  r  r  r  r  r  r   r   r   s   @r%   r   r     s3     .&.6/>%.N.$.$. .r(   r   c                   n   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tRtV tR# )TestPyReplOutputif  c                Z    \        V4      p\        R R7      p\        W#R7      pRVn        V# )Nr   r   F)r   r   r   can_colorizer   s   &&   r%   r   TestPyReplOutput.prepare_readerg  s-    f%48$WD#r(   c                     \         P                  ! \        P                  P	                  4       4      '       d   R #  V P                  R4       R #   \         d    pT P                  RT 24        R p?R # R p?ii ; i)Nzstdin is not a ttyzstdin tty check failed: )rY   isattyrV   rL   filenors   rn   r$   oses   & r%   test_stdin_is_tty"TestPyReplOutput.test_stdin_is_ttyn  sc    	0yy))+,, -
 MM./  	<MM4SE:;;	<   7A A:A55A:c                     \         P                  ! \        P                  P	                  4       4      '       d   R #  V P                  R4       R #   \         d    pT P                  RT 24        R p?R # R p?ii ; i)Nzstdout is not a ttyzstdout tty check failed: )rY   r#  rV   rM   r$  rs   rn   r%  s   & r%   test_stdout_is_tty#TestPyReplOutput.test_stdout_is_ttyx  sc    	1yy**,-- .
 MM/0  	=MM5cU;<<	=r)  c                    V P                  \        R 4      4      p\        V4      pV P                  VR4       V P	                  VRRR7       R# )z1+1
1+1TcleanN)r   r   r   r   assert_screen_equal)r$   r   ry   s   &  r%   
test_basicTestPyReplOutput.test_basic  sF    $$^G%<= ('  d ;r(   c                    V P                  \        R 4      4      p\        RRVR7      pV P                  \	        VP                  4       4      \        4       R# )rQ   N)f_inf_outr   )r   r   r   assertIstypeget_line_bufferr4   )r$   r   wrappers   &  r%    test_get_line_buffer_returns_str1TestPyReplOutput.test_get_line_buffer_returns_str  sA    $$^D%9:"DHd72245s;r(   c                D   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR	\	        R
4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R
4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pV P                  V4      p\        V4      pRpV P                  W44       V P                  W$RR7       \        V4      pRpV P                  W44       V P                  W$RR7       R# )zdef f():
...

r   r   r   r   r   r   r     g   gr   r   deleter  r   p   pa   as   srQ   r  zdef f():
    ...
    Tr/  zdef g():
    pass
    N	r   r   r   r   r   r   r   r   r1  )r$   r   r   ry   expecteds   &    r%   test_multiline_edit$TestPyReplOutput.test_multiline_edit  s   ./%d	)0DE%d	)0DE%f)I2FG%f)I2FG%f)I2FG%ky7IJ%cy?%f)I2FG%ky7IJ%hIg4FG%g9T?C%ky7IJ%cy?%cy?%cy?%cy?%d	%0@A%d	%0@A%
. $$V, (,*   > (-*   >r(   c                   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pV P                  V4      p\        V4      pV P                  VR4       V P                  VRRR	7       \        V4      pV P                  VR
4       V P                  VR
RR	7       \        V4      pV P                  VR
4       V P                  VR
RR	7       \        V4      pV P                  VR4       V P                  VRRR	7       R# )1+1
2+2
r   r   r   r   rQ   r  r.  Tr/  2+2NrH  r$   r   r   ry   s   &   r%   %test_history_navigation_with_up_arrow6TestPyReplOutput.test_history_navigation_with_up_arrow  sQ   <(%d	)0DE%d	%0@A%d	)0DE%d	)0DE%d	)0DE%d	%0@A

 $$V, ('  d ; ('  d ; ('  d ; ('  d ;r(   c                   R p\        \        P                  ! \        V4      \	        RR\        R4      R7      \	        RR\        R4      R7      \	        RR\        R4      R7      \	        RR\        R4      R7      \	        RR\        R4      R7      .4      4      pV P                  V4      p\        V4      p\        V4      p\        V4      pRpV P                  W5RR	7       V P                  WE4       R
# )z4def foo():
x = 1
y = 2
z = 3

def bar():
return 42

r   r   r   r   rQ   r  z-def foo():
    x = 1
    y = 2
    z = 3
    Tr/  N)
r5   r   r   r   r   r   r   r   r1  r   )r$   r   r   r   ry   rI  s   &     r%   #test_history_with_multiline_entries4TestPyReplOutput.test_history_with_multiline_entries  s    Mioo4 %d	)0DE%d	)0DE%d	)0DE%d	%0@A%d	%0@A	
 	 $$V, ( ( (F   >*r(   c                   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pV P                  V4      p\        V4      pV P                  VR	4       V P                  VR	R
R7       R# )rM  r   r   r   r   rQ   r  r   r   r.  Tr/  NrH  rO  s   &   r%   'test_history_navigation_with_down_arrow8TestPyReplOutput.test_history_navigation_with_down_arrow  s    <(%d	)0DE%d	)0DE%d	%0@A%f)I2FG%f)I2FG	
 $$V, ('  d ;r(   c                   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pV P                  V4      p\        V4      pV P                  VR	4       V P                  VR	R
R7       \        V4      pV P                  VR4       V P                  VRR
R7       \        V4      pV P                  VR4       V P                  VRR
R7       \        V4      pV P                  VR	4       V P                  VR	R
R7       R# )z1+1
2+2
3+3
r      r   1   1rQ   r  r.  Tr/  rN  z3+3NrH  rO  s   &   r%   test_history_search$TestPyReplOutput.test_history_search  s/   ,-%f)G2DE%cy?%d	%0@A%d	%0@A	
 $$V, ('  d ; ('  d ; ('  d ; ('  d ;r(   c                    \        R 4      pV P                  V4      p\        V4      pV P                  VR4       V P	                  VRRR7       R# )zc
zcTr/  N)r   r   r   r   r1  rO  s   &   r%   test_control_character'TestPyReplOutput.test_control_character  sK    	*$$V, ()   =r(   c                L   \         P                  ! \        R 4      \        R4      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pV P                  V4      p\        V4       \        V4      pV P                  VR4       V P                  VRR	R
7       R# )
import os
impr   page up   [5~r   rQ   r  	import osTr/  NrH  rO  s   &   r%   test_history_search_backward-TestPyReplOutput.test_history_search_backward  s    =)5!%iYz5JK%d	%0@A
 $$V, !(-  D Ar(   c                8   \         P                  ! \        R 4      \        RR\	        R4      R7      \        RR\	        R4      R7      .4      pV P                  V4      p\        V4       \        V4      pV P                  VR4       V P                  VRRR	7       R
# )rc  r   re  rf  r   rQ   r  rg  Tr/  NrH  rO  s   &   r%   "test_history_search_backward_empty3TestPyReplOutput.test_history_search_backward_empty*  s    =)%iYz5JK%d	%0@A
 $$V, !(-  D Ar(   r}   N)r   r   r   r   r   r'  r+  r2  r;  rJ  rP  rS  rV  r]  r`  rh  rk  r   r   r   s   @r%   r  r  f  sO     01<<
!?F<8+,<$<4>B(B Br(   r  c                      a  ] tR tRt o R t]! RR4      R 4       tR tR tR t	R	 t
]! R
4      ]! R]P                  R7      R 4       4       tRtV tR# )TestPyReplCompleteri>  c                    \        V4      p\        4       p\        P                  ! V4      P                  Vn        \        W4R 7      pV# r   )r   r   rlcompleter	Completercompleter   r   r$   r   	namespacer   r   r   s   &&&   r%   r   "TestPyReplCompleter.prepare_reader?  s<    f%!$/$9$9)$D$M$M!$WDr(   zrlcompleter._readline_availableFc                    \        R 4      pR\        /pV P                  W4      p\        W24      pV P	                  VR4       R# )zos.getpid	
rY   zos.getpid()Nr   rY   r   r   r   r$   r   ru  r   ry   s   &    r%   test_simple_completion*TestPyReplCompleter.test_simple_completionF  s?    02J	$$V7 3/r(   c                    \        R 4      pR\        /pV P                  W4      p\        W24      pV P	                  VR4       R# )zos.		O_AP	
rY   zos.O_APPENDNrx  ry  s   &    r%   !test_completion_with_many_options5TestPyReplCompleter.test_completion_with_many_optionsP  sB       122J	$$V7 3/r(   c                |    \        R 4      p/ pV P                  W4      p\        W24      pV P                  VR4       R# )z
os.geten	
zos.getenNr   ry  s   &    r%   test_empty_namespace_completion3TestPyReplCompleter.test_empty_namespace_completion^  s;    /	$$V7 3,r(   c                    \        R 4      pRR/pV P                  W4      p\        W24      pV P                  VR4       R# )zpy	
pythonNr   ry  s   &    r%    test_global_namespace_completion4TestPyReplCompleter.test_global_namespace_completionf  s@    )t$	$$V7 3*r(   c                   R pR\         /p\        P                  ! \        V4      \	        RR\        R4      R7      \	        RR\        R4      R7      \	        RR\        R4      R7      .\        R4      4      pV P                  W2R	7      p\        WB4      pV P                  VR
4       \        WB4      pV P                  VR4       R# )zimport os
os.		rY   r   r   r   r   r   r   rQ   ru  rg  zos.N)	rY   r   r   r   r   r   r   r   r   )r$   r   ru  r   r   ry   s   &     r%   'test_up_down_arrow_with_completion_menu;TestPyReplCompleter.test_up_down_arrow_with_completion_menum  s     $2J	4 %f)I2FG%d	)0DE%f)I2FG
 4 
 $$V$A 3- !3'r(   z,_pyrepl.readline._ReadlineWrapper.get_readerz
sys.stderr)new_callablec                     ! R  R4      pV! 4       p\        R4      pRV/pV P                  WV4      pWrn        \        \        RR4      pV P                  VR4       V P                  VP                  4       R4       R# )	c                   0   a  ] tR tRt o ]R 4       tRtV tR# )@TestPyReplCompleter.test_completion_with_warnings.<locals>.Dummyi  c                0    ^ RI pVP                  R4       R# )r   Nz	warnings
)warningswarn)r$   r  s   & r%   	test_funcJTestPyReplCompleter.test_completion_with_warnings.<locals>.Dummy.test_func  s    l+r(   r}   N)r   r   r   r   propertyr  r   r   r   s   @r%   Dummyr    s      r(   r  zdummy.test_func.	

dummyz>>>z...zdummy.test_func.__rS   N)r   r   return_valuereadline_multiline_inputr   r   getvalue)	r$   mock_stderrmock_get_readerr  r  r   ru  r   ry   s	   &&&      r%   test_completion_with_warnings1TestPyReplCompleter.test_completion_with_warnings  sx    	 	  89e$	$$V7'-$)*eUC!56--/4r(   r}   N)r   r   r   r   r   r	   rz  r}  r  r  r  ioStringIOr  r   r   r   s   @r%   rn  rn  >  sg      ,e40 500-+(2 9:
<bkk25 3 ;5r(   rn  c                      a  ] tR tRt o R tR tR tR t]! RR 4      ]! RR4      R	 4       4       t	]! R
R 4      R 4       t
R tR t]! RR 4      R 4       tR tR tR tR tRtV tR# )TestPyReplModuleCompleteri  c                    ^ RI p\        P                  P                  VP                  ^ ,          4      p\
        P                  V n        V.\
        n        R# )r   N)	importlibrY   rZ   dirname__path__rV   _saved_sys_path)r$   r  lib_paths   &  r%   r&   TestPyReplModuleCompleter.setUp  s9    
 77??9#5#5a#89"xx:r(   c                0    V P                   \        n        R # r~   )r  rV   rZ   r#   s   &r%   tearDown"TestPyReplModuleCompleter.tearDown  s    ''r(   c                    \        V4      p\        4       p\        V4      Vn        \        P
                  ! V4      P                  Vn        \        W4R 7      pV# rp  )	r   r   r   module_completerrq  rr  rs  r   r   rt  s   &&&   r%   r   (TestPyReplModuleCompleter.prepare_reader  sI    f%!"1)"<$/$9$9)$D$M$M!$WDr(   c                   RpV Fg  w  r#V P                  VR7      ;_uu_ 4        \        V4      pV P                  V/ R7      pVP                  4       pV P	                  Wc4       RRR4       Ki  	  R#   + '       g   i     K~  ; i)import path	
r   r  N))r  zimport pathlib)zimport importlib.		res	
zimport importlib.resources)z import importlib.resources.		a	
zimport importlib.resources.abc)zimport foo, impo	
zimport foo, importlib)zimport foo as bar, impo	
zimport foo as bar, importlib)zfrom impo	
zfrom importlib)zfrom importlib.res	
from importlib.resources)zfrom importlib.		res	
r  )zfrom importlib.resources.ab	
zfrom importlib.resources.abc)zfrom importlib import mac	
zfrom importlib import machinery)zfrom importlib import res	
zfrom importlib import resources)zfrom importlib.res	 import a	
z#from importlib.resources import abcsubTestr   r   readliner   r$   casesr   rI  r   r   ry   s   &      r%   test_import_completions1TestPyReplModuleCompleter.test_import_completions  ss    
 $ND4(('-,,Vr,B*  2	 )( $(((   A A22Bzpkgutil.iter_modulesc                 6    \        R RR4      \        R RR4      .# NpublicT_privater   r}   r(   r%   <lambda>"TestPyReplModuleCompleter.<lambda>  s    JtXt,L,6tZ,N,Pr(   zsys.builtin_module_namesc                   RpV Fg  w  r#V P                  VR7      ;_uu_ 4        \        V4      pV P                  V/ R7      pVP                  4       pV P	                  Wc4       RRR4       Ki  	  R#   + '       g   i     K~  ; i)	import 	
r  r  N))r  zimport public)zfrom 	
zfrom public)z
import _	
zimport _private)zfrom _	
zfrom _privater  r  s   &      r%   test_private_completions2TestPyReplModuleCompleter.test_private_completions  ss    
 $ND4(('-,,Vr,B*  2	 )( $(((r  z9_pyrepl._module_completer.ModuleCompleter.iter_submodulesc                 6    \        R RR4      \        R RR4      .# r  r   )r   s   *r%   r  r    s    tXt,tZ.
r(   c                   RpV Fg  w  r#V P                  VR7      ;_uu_ 4        \        V4      pV P                  V/ R7      pVP                  4       pV P	                  Wc4       RRR4       Ki  	  R#   + '       g   i     K~  ; i)from foo import 	
r  r  N))r  zfrom foo import public)zfrom foo import _	
zfrom foo import _privater  r  s   &      r%   #test_sub_module_private_completions=TestPyReplModuleCompleter.test_sub_module_private_completions  ss    
 $ND4(('-,,Vr,B*  2	 )( $(((r  c                   ^ RI p\        P                  P                  VP                  ^ ,          4      pV.\
        n        RpV Fg  w  rEV P                  VR7      ;_uu_ 4        \        V4      pV P                  V/ R7      pVP                  4       pV P                  W4       RRR4       Ki  	  R#   + '       g   i     K~  ; i)r   Nr  r  ))zimport bui	
zimport builtins)z
from bui	
zfrom builtins)r  rY   rZ   r  r  rV   r  r   r   r  r   )	r$   r  r  r  r   rI  r   r   ry   s	   &        r%   !test_builtin_completion_top_level;TestPyReplModuleCompleter.test_builtin_completion_top_level  s    
 77??9#5#5a#89:
 $ND4(('-,,Vr,B*  2	 )( $(((s   $A B22Cc                   RpV Fj  w  r#pV P                  VR7      ;_uu_ 4        \        V4      pV P                  VRV/R7      pVP                  4       pV P	                  Wt4       R R R 4       Kl  	  R #   + '       g   i     K  ; i)Nr  __package__r  ))Nfrom .readl	
zfrom .readl)Nfrom . import readl	
zfrom . import readl)_pyreplr  zfrom .readline)r  r  zfrom . import readliner  )r$   r  packager   rI  r   r   ry   s   &       r%    test_relative_import_completions:TestPyReplModuleCompleter.test_relative_import_completions  s{    
 (-#G84(('-,,Vw?W,X*  2	 )( (-(((s   AA55Bc                 6    \        R RR4      \        R RR4      .# )N
valid_nameTzinvalid-namer   r}   r(   r%   r  r    s    Jt\4,P,6t^T,R,Tr(   c                   RpV Fg  w  r#V P                  VR7      ;_uu_ 4        \        V4      pV P                  V/ R7      pVP                  4       pV P	                  Wc4       RRR4       Ki  	  R#   + '       g   i     K~  ; i)import valid	
r  r  N))r  zimport valid_name)zimport invalid	
zimport invalidr  r  s   &      r%   test_invalid_identifiers2TestPyReplModuleCompleter.test_invalid_identifiers  ss    


 $ND4(('-,,Vr,B*  2	 )( $(((r  c                   RpV Fg  w  r#V P                  VR7      ;_uu_ 4        \        V4      pV P                  V/ R7      pVP                  4       pV P	                  Wc4       RRR4       Ki  	  R#   + '       g   i     K~  ; i)import pri	
r  r  N))r  z
import pri)z
from pri	
zfrom pri)zfrom typing import Na	
zfrom typing import Nar  r  s   &      r%   &test_no_fallback_on_regular_completion@TestPyReplModuleCompleter.test_no_fallback_on_regular_completion"  ss    

 $ND4(('-,,Vr,B*  2	 )( $(((r  c                    Rp\        4       pV FI  w  r4V P                  VR7      ;_uu_ 4        V P                  VP                  V4      V4       RRR4       KK  	  R#   + '       g   i     K`  ; i)rS   )rC   N))rS   )rS   rS   ).)r  rS   )..)r  rS   ).foo)r  foo)..foo)r  r  )z..foo.)r  rS   )	..foo.bar)r  bar)z	.foo.bar.)z.foo.barrS   )z
..foo.bar.)r  rS   )r  )rS   r  )zfoo.r  rS   )foo.bar)r  r  )zfoo.bar.)r  rS   )zfoo.bar.baz)r  baz)r   r  r   get_path_and_prefix)r$   r  	completerrC   rI  s   &    r%   test_get_path_and_prefix2TestPyReplModuleCompleter.test_get_path_and_prefix/  s]    
  $%	#ND4((  !>!>t!DhO )( $(((s   "AA/c                   RpV F  w  r#\        V4      pVP                  4       pV P                  VR7      ;_uu_ 4        V P                  WS4       RRR4       RV 2p\        V4      pVP                  4       pV P                  VR7      ;_uu_ 4        V P                  WS4       RRR4       RV 2p\        V4      pVP                  4       pV P                  VR7      ;_uu_ 4        V P                  WS4       RRR4       K  	  R#   + '       g   i     L; i  + '       g   i     L}; i  + '       g   i     EK:  ; i)import Nr  zimport xyz
zimport xyz;)#)r  NrS   )z
import fooNr  )zimport foo,r  )zimport foo, r  )zimport foo, bar)Nr  )zimport foo, bar, bazNr  )zimport foo as bar,r  )zimport foo as bar, r  )zimport foo as bar, bazr  )z	import a.)Na.)z
import a.b)Na.b)zimport a.b.)Na.b.)zimport a.b.c)Na.b.c)zimport a.b.c, foor  )zimport a.b.c, foo.bar)Nr  )zimport a.b.c, foo.bar,r  )zimport a.b.c, foo.bar, r  )zfrom foo)r  N)zfrom a.)r  N)zfrom a.b)r  N)z	from a.b.)r  N)z
from a.b.c)r  N)zfrom foo import r  )zfrom foo import ar  rD  )zfrom )rS   N)zfrom . import a)r  rD  )zfrom .foo import a)r  rD  )zfrom ..foo import a)r  rD  )zfrom foo import (r  )zfrom foo import ( r  )zfrom foo import (ar  )zfrom foo import (a,r  )zfrom foo import (a, r  )zfrom foo import (a, cr  c)zfrom foo import (a as b, cr  r   parser  r   )r$   r  r   parsedparseractual_codes   &      r%   
test_parse$TestPyReplModuleCompleter.test_parseE  s    $
J "LD!$'F\\^F4((  0 ) #4&)E!%(F\\^F5))  0 *!$(E!%(F\\^F5))  0 *) " )( *)
 *))s#   DD'D-DD*-D?c                    RpV FS  p\        V4      pVP                  4       pV P                  VR7      ;_uu_ 4        V P                  VR4       RRR4       KU  	  R#   + '       g   i     Kj  ; i)rS   r  N))rS   zimport foo 	from foo zimport foo. zimport foo.bar r  z
from foo. zfrom foo.bar zfrom foo import bar zfrom foo import (bar zfrom foo import bar, baz zimport foo aszimport a. aszimport a.b aszimport a.b. aszimport a.b.c aszimport (foozimport (zimport .foozimport ..foozimport .foo.barzimport foo; x = 1zimport a.; x = 1zimport a.b; x = 1zimport a.b.; x = 1zimport a.b.c; x = 1zfrom foo import a aszfrom foo import a. aszfrom foo import a.b aszfrom foo import a.b. aszfrom foo import a.b.c aszfrom foo impozimport importzimport fromz	import aszfrom importz	from fromzfrom aszfrom foo import importzfrom foo import fromzfrom foo import asr  )r$   r  r   r  r  s   &    r%   test_parse_error*TestPyReplModuleCompleter.test_parse_error}  s`    *
V D!$'F\\^F4((  . )(  )((s   AA/)r  Nr}   )r   r   r   r   r&   r  r   r  r	   r  r  r  r  r  r  r  r  r  r   r   r   s   @r%   r  r    s     (3, ! $P Q
%r*3 +Q3  C	
333(3 ! $T U3U33P,61p0/ 0/r(   r  c                   J   a  ] tR tRt o R tR tR tR tR tR t	R t
R	tV tR
# )TestPasteEventi  c                L    \        V4      p\        R R7      p\        W#R7      pV# r   r   r   s   &&   r%   r   TestPasteEvent.prepare_reader  r   r(   c                   R p\         P                  ! \        RR\        R4      R7      .\	        V4      \        RR\        R4      R7      .\	        R4      4      pV P                  V4      p\        V4      pV P                  WA4       R# )zOdef a():
  for x in range(10):
    if x%2:
      print(x)
    else:
      pass
r   f3   ORr   rQ   Nr   r   r   r   r   r   r   r   r$   r   r   r   ry   s   &    r%   
test_pasteTestPasteEvent.test_paste  s     	 %d	)0DE 4 %d	)0DE 4 	
 $$V, (&r(   c                   R p\         P                  ! \        RR\        R4      R7      .\	        V4      \        RR\        R4      R7      .\	        R4      4      pV P                  V4      p\        V4      pV P                  WA4       R# )zdef f():
  x = y
  
  y = z
r   r
  r  r   rQ   Nr  r  s   &    r%   test_paste_mid_newlines&TestPasteEvent.test_paste_mid_newlines  s     	 %d	)0DE 4 %d	)0DE 4 	
 $$V, (&r(   c                ~    R pRp\        V4      pV P                  V4      p\        V4      pV P                  WR4       R# )zdef f():
x = y

y = z

zdef f():
    x = y
    Nr   )r$   r   rI  r   r   ry   s   &     r%   )test_paste_mid_newlines_not_in_paste_mode8TestPasteEvent.test_paste_mid_newlines_not_in_paste_mode  sJ     	 	  %$$V, (*r(   c                ~    R pRp\        V4      pV P                  V4      p\        V4      pV P                  WR4       R# )z:def a():
for x in range(10):
if x%2:
print(x)
else:
pass

zWdef a():
    for x in range(10):
        if x%2:
            print(x)
            else:Nr   r   s   &     r%   test_paste_not_in_paste_mode+TestPasteEvent.test_paste_not_in_paste_mode  sJ    # 	  	  
+$$V, (-r(   c                    R pR pRpRp\         P                  ! \        V4      \        V4      \        V4      \        R4      4      pV P                  V4      p\	        V4      pV P                  Wr4       R# )zQdef a():
  for x in range(10):

    if x%2:
      print(x)

    else:
      pass
[200~[201~rQ   Nr   r   r   r   r   r   )r$   r   r   paste_start	paste_endr   r   ry   s   &       r%   test_bracketed_paste#TestPasteEvent.test_bracketed_paste  sz     	 	 "	;':&9%4 	
 $$V, (-r(   c                    R pRpRp\         P                  ! \        V4      \        V4      \        V4      \        R4      4      pV P                  V4      p\	        V4      pV P                  Wa4       R# )oneliner  r  rQ   Nr  )r$   r   r  r  r   r   ry   s   &      r%    test_bracketed_paste_single_line/TestPasteEvent.test_bracketed_paste_single_line=  si    
!	;':&9%4 	
 $$V, (,r(   r}   N)r   r   r   r   r   r  r  r  r  r  r#  r   r   r   s   @r%   r  r    s.     '4'0+*.2%.N- -r(   r  zrequires ptyc                   &   a  ] tR tRt o R tRtV tR# )TestDumbTerminaliN  c                F   \         P                  P                  4       pVP                  R R4       VP	                  RR/4       V P                  RVR7      w  r#V P                  V^ 4       V P                  RV4       V P                  RV4       V P                  RV4       R# )	PYTHON_BASIC_REPLNTERMdumbzexit()
r1   zwarning: can't use pyrepl	Exception	Traceback)	rY   rf   copypopupdaterG   r   assertInassertNotIn)r$   r1   ry   r{   s   &   r%    test_dumb_terminal_exits_cleanly1TestDumbTerminal.test_dumb_terminal_exits_cleanlyP  s    jjoo#T*

FF#$ MM*#M>A&16:f-f-r(   r}   N)r   r   r   r   r3  r   r   r   s   @r%   r&  r&  N  s     . .r(   r&  r)  r*  z!can't use pyrepl in dumb terminalc                   @  a a ] tR tRt oV 3R lt]R 4       tV3R lR lt]RRRRR	R/R
 l4       tR t	R t
R tR tR tR t]R 4       t]R 4       tR t]R 4       tR t]R 4       t]R 4       tR t]R 4       tR tR tR tR t]! ]R4      R 4       tR tVt V ;t!# )!TestMaini[  c                   < \         SV `  4        \        R \        4       R7      pV P	                  VP
                  4       VP                  4        R# )z
os.environ)newN)superr&   r	   r   
addCleanupstopstart)r$   patcher	__class__s   & r%   r&   TestMain.setUp^  s6     	.*:;%r(   c                   R pRpV P                  RR.RR7      w  r4V P                  V^ 4       V RV 2V9   pV RV 2V9   pV RV 2V9   pV R	V 2V9   pT P                  T;'       g    T;'       g    T;'       g    TV4       R
# )z['__builtins__'z4'__loader__', '__name__', '__package__', '__spec__']zsorted(dir())exit()T)r+   z, '__doc__', z, '__doc__', '__file__', z', '__cached__', '__doc__', '__file__', z, '__cached__', '__doc__', N)rG   r   
assertTrue)	r$   prepostry   r{   case1case2case3case4s	   &        r%   test_exposed_globals_in_repl%TestMain.test_exposed_globals_in_replg  s    E MM?H*EDMQA& %}TF+v5 %076A %>tfEO %24&9VC8888%885&Ar(   c                T   < V ^8  d   QhRS[ RS[ S[P                  ,          RS[ RR/# )r/   varrI  r  r2   N)r4   rePattern)r;   r<   s   "r%   r=   TestMain.__annotate__|  s6      &)BJJ&6@C	r(   c                    \        V\        P                  4      '       d6   V P                  VP	                  V4      V R V RVP
                   24       R# V P                  VVRV R V RV R V 24       R# )=z does not match z	expected z, got N)rh   rM  rN  rB  matchpatternr   )r$   rL  rI  r  s   &&&&r%   _assertMatchOKTestMain._assertMatchOK|  s{     h

++OOv&%q 01A1A0BC
 C5(6#ax@r(   as_fileF	as_modulepythonstartupc          
        \        4       pR VR&   \        P                  ! 4       ;_uu_ 4       p\        P                  ! V4      R,          pVP                  4        VR,          pVP                  RRR7       VR,          p	V	P                  RRR7       V U
u. uF  p
R	V
,           R
,           NK  	  up
R.,           pV'       d   \        V	4      VR&   V'       d   V'       d   V P                  R4       MeV'       d#   V P                  V\        V4      .VRR7      w  rM;V'       d   V P                  VRR.VVRR7      w  rMV P                  V. VVRR7      w  rRRR4       V P                  X^ 4       VP                  4        F  w  rV P                  WR7      ;_uu_ 4        \        P                  ! RV
 R2X4      ;p'       d$   V P                  WVP!                  ^4      R7       MV P                  V
 RV: RV 24       RRR4       K  	  V P#                  RX4       V P#                  RV4       R# u up
i   + '       g   i     L; i  + '       g   i     K  ; i)r[  NO_COLORbluezcalx.pyzFOO = 42rR   )encodingz
startup.pyzBAR = 64z
print(f'^{z=}')rA  PYTHONSTARTUPz,as_file and as_module are mutually exclusiveT)r)   r1   r+   z-mz	blue.calx)r)   r1   r*   r+   N)rL  rI  z\^z=(.+?)[\r\n])r  z= not found in output: z

r,  r-  )r   rA   rB   pathlibPathmkdir
write_textr4   rq   rG   r   itemsr  rM  searchrT  groupr2  )r$   expectationsrV  rW  rX  	clean_envtdr[  modstartuprL  commandsry   r{   rI  ms   &&$$$           r%   _run_repl_globals_testTestMain._run_repl_globals_test  s.   "$	 #	*((**b<<#f,DJJL"CNN:N8\)GzG<7C7Cs"V++|
H -0\	/*9		HI$(MM"%c(!	 %2 %!	 $(MM"&!4! %2 %!	 %)MM!#! %2 %!= +L 	A&)//1MC#99		RuL"96BB1B''aggaj'III%<VJd6(ST	 :9 2 	f-f-Q +*P :99sI   A*H9H40H9H9H9!H9;)H9%3H9!A!I4H99I		Ic                4    R RRR/pV P                  V4       R# )r   
'__main__'r  NoneNrl  r$   re  s   & r%   #test_globals_initialized_as_default,TestMain.test_globals_initialized_as_default  s#    6

 	##L1r(   c                <    R RRRRR/pV P                  VRR7       R# )	BAR64r   ro  r  rp  T)rX  Nrq  rr  s   & r%   +test_globals_initialized_from_pythonstartup4TestMain.test_globals_initialized_from_pythonstartup  s-    46
 	##L#Er(   c                <    R RRRRR/pV P                  VRR7       R# )	FOO42r   ro  r  rp  T)rV  Nrq  rr  s   & r%   .test_inspect_keeps_globals_from_inspected_file7TestMain.test_inspect_keeps_globals_from_inspected_file  s-    46
 	##L$#?r(   c                B    R RRRRRRR/pV P                  VRRR	7       R
# )r{  r|  rv  rw  r   ro  r  rp  T)rV  rX  Nrq  rr  s   & r%   Atest_inspect_keeps_globals_from_inspected_file_with_pythonstartupJTestMain.test_inspect_keeps_globals_from_inspected_file_with_pythonstartup  s4    446	
 	##L$d#Sr(   c           
     h    R RRRRRR\         P                  ! R4      /pV P                  VRR	7       R
# )r{  r|  r   ro  r  'blue'__file__^'.*calx.py'$T)rW  NrM  compilerl  rr  s   & r%   0test_inspect_keeps_globals_from_inspected_module9TestMain.test_inspect_keeps_globals_from_inspected_module  s<    48

#34	
 	##LD#Ar(   c                n    R RRRRRRRR\         P                  ! R	4      /pV P                  VR
R
R7       R# )r{  r|  rv  rw  r   ro  r  r  r  r  T)rW  rX  Nr  rr  s   & r%   Ctest_inspect_keeps_globals_from_inspected_module_with_pythonstartupLTestMain.test_inspect_keeps_globals_from_inspected_module_with_pythonstartup  sD    448

#34
 	##LDPT#Ur(   c                   \         P                  P                  4       pR pVP                  RR4       V P	                  W!RR7      w  r4V P                  V^ 4       V P                  RV4       V P                  RV4       V P                  RV4       RpR	VR&   V P	                  WQR
7      w  r4V P                  V^ 4       V P                  RV4       V P                  RV4       V P                  RV4       RpR	VR&   V P	                  WaR
7      w  r4V P                  V^ 4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       R# )zclear
exit()
r(  NTr1   r+   r,  	NameErrorr-  zhelp
exit()
r[  r+  z Type help() for interactive helpz2import sys
print('_pyrepl' in sys.modules)
exit()
FalseTrue)rY   rf   r.  r/  rG   r   r2  r1  )r$   r1   pyrepl_commandsry   r{   basic_commandsrj  s   &      r%   test_python_basic_replTestMain.test_python_basic_repl  sR   jjoo+#T* MM/MNA&f-f-f-)#&  MM.MBA&8&Af-f- $'  MM(M<A&gv&(f-f-r(   c           	        \         P                  P                  \        R R4      pV P	                  \         P                  P                  V4      V4       \        V4      ;_uu_ 4       pVP                  4       pRRR4       \        \        R\        \        P                  X4      4      4      pR F  pV P                  WC4       K  	  R#   + '       g   i     LY; i)r  z__main__.pyN)?zunknown-filenamez<foo>z<...>)rY   rZ   r[   r   rB  existsopen	readlinesr5   filtermapr4   strip_test_no_pyrepl_source_in_exc)r$   pyrepl_main_filefpexcluded_linesfilenames   &    r%   test_no_pyrepl_source_in_exc%TestMain.test_no_pyrepl_source_in_exc  s     77<<
I}M'78:JK"##r\\^N $fT3syy.+IJKCH..xH D	 $#s   (C

C	c                   \        4       ;_uu_ 4       q0P                  VR 7      ;_uu_ 4        VP                  R4       RV: R2pV P                  WCR7      w  rVV P	                  RV4       V P	                  RV4       V F7  pV P                  VR7      ;_uu_ 4        V P                  Wu4       RRR4       K9  	  RRR4       RRR4       R#   + '       g   i     K^  ; i  + '       g   i     L.; i  + '       g   i     R# ; i)	)r  r(  zeval(compile('spam', z, 'eval'))
exit()
r+  z!Traceback (most recent call last)z%NameError: name 'spam' is not defined)lineN)r   r  unsetrG   r1  r2  )r$   r  r  r1   rj  ry   r   r  s   &&&     r%   r  &TestMain._test_no_pyrepl_source_in_exc$  s     ""c<<<+J+JII)*/| <# $Hh8IFMM=vFMMA6J&\\t\,,$$T2 -, ' ,K"" -,, ,K+J"""s;   C4A0C!	C/C!	;C4C	C!	!C1,C44D	c                   a  \         P                  P                  4       pR pV 3R lpVP                  RR4       S P	                  W!RR7      w  rEV! WE4       RVR&   S P	                  W!R7      w  rEV! WE4       R# )z)import sys
sys.excepthook = 1
1/0
exit()
c                    < SP                  R V 4       SP                  V P                  R4      ^4       SP                  RV 4       SP                  RV 4       SP                  V^ 4       R# )zError in sys.excepthook:z'int' object is not callablezOriginal exception was:zdivision by zeroN)r1  r   count)ry   exitcoder$   s   &&r%   checkCTestMain.test_bad_sys_excepthook_doesnt_crash_pyrepl.<locals>.check8  sZ    MM4f=V\\*HI1MMM3V<MM,f5Xq)r(   r(  NTr  r[  r+  )rY   rf   r.  r/  rG   )r$   r1   rj  r  ry   r{   s   f     r%   +test_bad_sys_excepthook_doesnt_crash_pyrepl4TestMain.test_bad_sys_excepthook_doesnt_crash_pyrepl0  ss    jjoo
	* 	#T* MM($MGf #&  MM(M<f r(   c                   \        R 4       \        P                  ! RR7      pV P                  \        VP
                  4       \        P                  P                  4       pVP
                  VR&   RpVP                  RR4       V P                  W2R7      w  rEV P                  V^ 4       V P                  RV4       V P                  R	V4       V P                  \        P                  ! VP
                  4      P!                  4       P"                  ^ 4       VP$                  P'                  4        VP)                  4        R
VR&   V P                  W2R7      w  rEV P                  V^ 4       V P                  RV4       V P                  R	V4       V P                  \        P                  ! VP
                  4      P!                  4       P"                  ^ 4       R# )r  F)rA  rK   z123
spam
exit()
r(  Nr+  123spamr[  )r   rA   NamedTemporaryFiler:  r   rC   rY   rf   r.  r/  rG   r   r1  assertNotEqualr^  r_  statst_sizefiletruncaterg   )r$   hfiler1   rj  ry   r{   s   &     r%   test_not_wiping_history_file%TestMain.test_not_wiping_history_fileF  sY   j!++59

+jjoo %

(#T* MM(M<A&eV$ff%GLL499;CCQG

#&  MM(M<A&eV$ff%GLL499;CCQGr(   c                ,   \         P                  P                  4       pR pV P                  W!RR7      w  r4V P	                  RV4       V P	                  RV4       RpV P                  W!R7      w  r4V P	                  RV4       V P	                  RV4       R# )	za b c
exit()
Tr  zSyntaxError: invalid syntaxz<python-input-0>z
 b
exit()
r+  z#IndentationError: unexpected indentN)rY   rf   r.  rG   r1  )r$   r1   rj  ry   r{   s   &    r%   %test_correct_filename_in_syntaxerrors.TestMain.test_correct_filename_in_syntaxerrorsa  s    jjoo$ MM($MG3V<(&1! MM(M<;VD(&1r(   c           
        \         P                  P                  4       pR EF  pRV'       d   RMR,           R,           pR F  pV'       d   RVR&   MVP                  RR4       V P	                  VVR7      ;_uu_ 4        V P                  W1R R	7      w  rVV P                  R
V4       V'       d8   V P                  RV4       V P                  RV4       V P                  RV4       M6V P                  RV4       V P                  RV4       V P                  RV4       RRR4       K  	  EK
  	  R#   + '       g   i     K  ; i)Tzimport sys
zsys.tracebacklimit = 1
rS   z;def x1(): 1/0

def x2(): x1()

def x3(): x2()

x3()
exit()
r[  r(  N)set_tracebacklimit
basic_replr  zin x1zin x2zin x3zin <module>)TF)rY   rf   r.  r/  r  rG   r1  r2  )r$   r1   r  rj  r  ry   r{   s   &      r%   test_proper_tracebacklimit#TestMain.test_proper_tracebacklimitm  s   jjoo"/&7I3rS##H ,
/2C+,GG/6\\5G-7 " 9 9(,hd(S%FMM'62)((&9((&9((?gv6gv6mV<9 9 , #09 9 9s   ?BD/	/E c                t    V P                  R 4      w  rV P                  V^ 4       V P                  RV4       R# )z	 
exit()
	TypeErrorN)rG   r   r2  r$   ry   r{   s   &  r%   test_null_byteTestMain.test_null_byte  s4     MM*:;A&f-r(   c                    R pV P                  V4      w  r#V P                  V^ 4       V P                  RV4       V P                  RV4       R# )zNimport runpy
runpy._run_module_code('blech', {0: '', 'bluch': ''}, '')
exit()
z,all elements in 'candidates' must be stringsbluchN)rG   r   r2  r1  )r$   rj  ry   r{   s   &   r%   %test_non_string_suggestion_candidates.TestMain.test_non_string_suggestion_candidates  sK     !MM(3A&GPgv&r(   c                   \        R 4      pVP                  R8w  d   V P                  R4       \        P                  ! 4       ;_uu_ 4       p\
        P                  P                  4       pVP                  VR&   RVR&   V P                  RVR7      w  rEV P                  V^ 4       V P                  RV4       V P                  \        P                  ! VP                  4      P                  4       P                   ^ 4       V P                  R	\        P                  ! VP                  4      P#                  4       4       VP%                  RR
4       V P                  RVR7      w  rEV P                  V^ 4       V P'                  R\        P                  ! VP                  4      P#                  4       4       R
R
R
4       R
#   + '       g   i     R
# ; i)r  editlinez*GNU readline is not affected by this issuerK   r[  r(  zspam 
exit()
r+  zspam zspam\040Nzexit
z\040)r   backendrs   rA   r  rY   rf   r.  rC   rG   r   r1  r  r^  r_  r  r  	read_textr/  r2  )r$   r  r  r1   ry   r{   s   &     r%   test_readline_history_file#TestMain.test_readline_history_file  sO    ,z)MMFG((**e**//#C$)JJC !'*C#$ $.?S IFY*MM'6*UZZ 8 = = ? G GKMM+w||EJJ'?'I'I'KLGG'. $hC @FY*Wgll5::&>&H&H&JK +***s   E)F>>G	c                   \         P                  P                  4       p\        P                  ! 4       ;_uu_ 4       pVP
                  VR &   RpV P                  W1RR7      w  rERp V P                  W1^R7       \        P                  ! VP
                  4      P                  4       pV P                  RV4       V P                  RV4       V P                  RV4       V P                  R	V4       V P                  R
V4       V P                  RV4       RRR4       R#   \         d     Li ; i  + '       g   i     R# ; i)rK   z1
2
3
exit()
Tr  z'spam
import time
time.sleep(1000)
quit
)r1   r,   2rA  r  zimport timesleepquitN)rY   rf   r.  rA   r  rC   rG   AssertionErrorr^  r_  r  r1  r2  )r$   r1   r  rj  ry   r{   historys   &      r%   test_history_survive_crash#TestMain.test_history_survive_crash  s   jjoo((**e$)JJC !*H $hd KFDHh; ll5::.88:GMM#w'MM(G,MM&'*MM-1Wg.VW-% +* "  +**s0   )D.&D9BD.D+(D.*D++D..D?	c                P    V P                  R 4      w  rV P                  V^ 4       R# )zexit
N)rG   r   r  s   &  r%   %test_keyboard_interrupt_after_isearch.TestMain.test_keyboard_interrupt_after_isearch  s$     MM*:;A&r(   c                    V P                  . RO4      w  r\        P                  ! R4      pVP                  RV4      pV P	                  V^ 4       V P                  RV4       R# )helpz"(\x1B(=|>|(\[)[0-?]*[ -\/]*[@-~]))rS   z>>> 
>>> >>>N)r  qexit)rG   rM  r  subr   r2  )r$   ry   r{   ansi_escapecleaned_outputs   &    r%   test_prompt_after_helpTestMain.test_prompt_after_help  sW     MM*?@ jj!FG$V4A&
 	.9r(   z--X showrefcount requires a Python debug buildc                   \         P                  P                  4       pVP                  R R4       V P	                  RR.VR7      w  r#\
        P                  ! RV4      pV P                  \        V4      ^4       RVR &   V P	                  RR.VR7      w  r#\
        P                  ! RV4      pV P                  \        V4      ^4       R# )r(  rS   z1
1+2
exit()
z-Xshowrefcount)r)   r1   z\[-?\d+ refs, \d+ blocks\]r[  N)	rY   rf   r.  r/  rG   rM  findallr   r   )r$   r1   ry   r   matchess   &    r%   test_showrefcountTestMain.test_showrefcount  s    jjoo#R(MM"4DTCU[^M_	**:FCWq)#& MM"4DTCU[^M_	**:FCWq)r(   r}   )"r   r   r   r   r&   r
   rI  rT  rl  rs  rx  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r  r   r   __classcell__)r>  r<   s   @@r%   r6  r6  [  s9     B B(  3.e 3.u 3.di 3. 3.j2F@TBV . .< 
I 
I
3 ! !*H6 	2 	2 = =:.
 ' 'L,..': IJ
* K
* 
*r(   r6  )>r  r   rY   r^  rM  rq  rk   rd   rV   rA   pkgutilr   unittestr   r   r   r   unittest.mockr	   test.supportr
   r   r   r   r   r   test.support.import_helperr   test.support.os_helperr   r   supportr   r   r   r   r   r   r   _pyrepl.consoler   _pyrepl._module_completerr   r   _pyrepl.readliner   r   r   r  rT   ImportErrorr!   r   r   r  rn  r  r  r&  rf   getr6  r}   r(   r%   <module>r     sd   	  	  	    
   ; ;  F F J J 4 >   " C0 0 H
e!8 e!Pd- d-N	l.8 l.^UB' UBpZ5( Z5zR/ R/h\-X \-~ C 	.| 	. !	. C 		)	)6f46YZG*| G* [ !G*s)  
Cs   E 	EE