+
    Bi$L              	          ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^RIHtHt ^RIHtHt ^RIHtHt ^ R	IHt ^ R
IHt ^ RIHt RRRR/t]P4                  P7                  4        U Uu/ uF,  w  r]P9                  W ^ ,          P;                  4       4      VbK.  	  upp t] ! R R]]4      4       t]
 ! R R]]4      4       t R# u upp i )    N)dedent)TestCase)	MagicMock)force_colorized_test_classforce_not_colorized_test_class)handle_all_eventshandle_events_narrow_console)ScreenEqualMixincode_to_events)prepare_readerprepare_console)Event)Reader)default_themeresetzsoft_keywordKc                      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R tR tR tR tRtV tR# )
TestReaderc                `    \        R4      p\        V4      w  r#V P                  VR R24       R# )
   \
aN
aaaaaaaaaa	aaaaaaaaar   r	   assert_screen_equalselfeventsreader_s   &   3/usr/lib/python3.14/test/test_pyrepl/test_reader.pytest_calc_screen_wrap_simple'TestReader.test_calc_screen_wrap_simple   s.    )08	  E7%9    c                `    \        R4      p\        V4      w  r#V P                  VR R24       R# )   u   \
樂Naaaaaaaau   aaaaaaaa樂r   r   s   &   r#   %test_calc_screen_wrap_wide_characters0TestReader.test_calc_screen_wrap_wide_characters   s/    008	  E7'):;r&   c                f    \        R4      p\        V4      w  r#V P                  VR RR R24       R# )   z\
z\
aaNaaaaaaaaaaaaaaaaaaaar   r   r   s   &   r#   !test_calc_screen_wrap_three_lines,TestReader.test_calc_screen_wrap_three_lines!   s5    )08	  E7$ugV)DEr&   c                d    R  p\        R4      p\        VVR7      w  r4V P                  VR4       R# )c                  t    \        V / VB pV=R Vn        R Vn        RVn        RVn        RVn        RVn        V# )>>> z...  F)r   
get_promptps1ps2ps3ps4can_colorize
paste_mode)argskwargsr!   s   *, r#   prepare_reader_keep_promptsPTestReader.test_calc_screen_prompt_handling.<locals>.prepare_reader_keep_prompts'   sH    #T4V4F!FJFJFJFJ"'F %FMr&   z"if some_condition:
some_function()r   z6>>> if so\
me_condit\
ion:
...     s\
ome_funct\
ion()Nr   )r   r>   r    r!   r"   s   &    r#    test_calc_screen_prompt_handling+TestReader.test_calc_screen_prompt_handling&   s>    		   EF06
	
 	  
	
r&   c                |    R R RR 2p\        V4      p\        V4      w  r4V P                  VR R	 RR
 R2RR7       R# )zdef f():
  z
  z\
a
  u   \
樂樂TcleanNr)   u   樂樂樂樂樂aaaaaaau	   樂樂樂r   r   coder    r!   r"   s   &    r#   1test_calc_screen_wrap_three_lines_mixed_character<TestReader.test_calc_screen_wrap_three_lines_mixed_characterE   ss    w y 	  %08	 	  7 9   	! 
	
r&   c           
         \         P                  ! \        R 4      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VR4       R# )aaakey	backspace   evtdatarawaaN)	itertoolschainr   r   	bytearrayr   r   r   s   &   r#   test_calc_screen_backspace%TestReader.test_calc_screen_backspace_   sL    5!%ky7IJ
 &f-	  .r&   c           
         \         P                  ! \        R4      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VR4       R# )r   rM   rN   rO   rP   Nr   r   rU   rV   r   r   rW   r	   r   r   s   &   r#   -test_calc_screen_wrap_removes_after_backspace8TestReader.test_calc_screen_wrap_removes_after_backspacei   sL    8$%ky7IJ
 18	  1r&   c           
         \         P                  ! \        R4      \        RR\	        R4      R7      .4      p\        V4      w  r#V P                  VR R24       R# )	   rM   rN   rO   rP   r   Naaaaaaaaaaar   r[   r   s   &   r#   4test_calc_screen_backspace_in_second_line_after_wrap?TestReader.test_calc_screen_backspace_in_second_line_after_wraps   sR    8$%ky7IJ
 18	  E7%9r&   c                    \        R 4      p\        V4      w  r#VP                  ^ ^ 4       V P                  VP                  ^ 4       R# )z11+11Nr   r   setpos_from_xyassertEqualposr   s   &   r#   test_setpos_for_xy_simple$TestReader.test_setpos_for_xy_simple}   s<    (%f-	a#Q'r&   c                    R p\        V4      p\        V4      w  r4VP                  ^^4       V P                  VP                  ^4       R# )zdef foo():
  return 1Nrd   rG   s   &    r#   "test_setpos_from_xy_multiple_lines-TestReader.test_setpos_from_xy_multiple_lines   sH     	  %%f-	a#R(r&   c                    R p\        V4      p\        V4      w  r4VP                  ^^4       V P                  VP                  ^4       R# zdef foo():
  helloNr   r	   re   rf   rg   rG   s   &    r#   test_setpos_from_xy_after_wrap)TestReader.test_setpos_from_xy_after_wrap   sH     	  %08	a#R(r&   c                    R p\        V4      p\        V4      w  r4VP                  ^ ^4       V P                  VP                  ^	4       R# rn   ro   rG   s   &    r#   "test_setpos_fromxy_in_wrapped_line-TestReader.test_setpos_fromxy_in_wrapped_line   sH     	  %08	a#Q'r&   c           
         \        \        R R\        R4      R7      \        R R\        R4      R7      .4      p\        V4      w  r#V P	                  VR4       R# )rM      rP   up   OAr4   N)iterr   rW   r   r   r   s   &   r#   test_up_arrow_after_ctrl_r%TestReader.test_up_arrow_after_ctrl_r   sQ    %f)G2DE%d	)0DE
 &f-	  ,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      \        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\
        P                  ! \        RR7      p\        W#R7      w  rERpV P                  WFRR7       V P                  VP                  4       R# )zdef foo():
a = 1
rM   rx   ry   rP   s   O5
   
downs   OBF)r;   r@   z(def foo():
    
    
    a = 1
    
    TrD   N)rU   rV   r   r   rW   	functoolspartialr   r   r   
assertTruefinished)r   rH   r    no_paste_readerr!   r"   expecteds   &      r#   -test_newline_within_block_trailing_whitespace8TestReader.test_newline_within_block_trailing_whitespace   s    	 4  %d	)0DE%d	)0DE%f)I2FG%d	%0@A%d	%0@A%f)I2FG%f)I2FG %d	%0@A%d	%0@A
( $++NuM%fM	 	 	   >(r&   c                   a \        4       oV3R  lp\        R4      p\        W!R7      w  r4V P                  \	        SP
                  4      ^4       R# )c                 f   < \        4       pWP                  n        ^dVn        ^PVn        SVn        V# )d   )r   	get_eventside_effectheightwidth
input_hook)r    consoler   s   & r#   _prepare_consoleETestReader.test_input_hook_is_called_if_set.<locals>._prepare_console   s1    kG,2) GNGM!+GNr&   a)r   N)r   r   r   rf   len
mock_calls)r   r   r    r!   r"   r   s   &    @r#    test_input_hook_is_called_if_set+TestReader.test_input_hook_is_called_if_set   sB    [
	  $%fO	Z223Q7r&   c                p   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      .4      p\        V4      p\        V\        P                  ! V4      P                  R7      p  VP                  4        K    \         dt    T P                  \        TP                  4      ^8  4       TP!                  4        T P#                  \        TP                  4      ^4       T P%                  YRR	R
7        R# i ; i)rU   zimport itertools
itertools.rM   	   	rP      readline_completerTrD   N)rU   rV   r   r   rW   r   r   rlcompleter	Completercompletehandle1failKeyboardInterruptr   r   screenrefreshrf   r   )r   	namespacerH   r    r   r!   s   &     r#   %test_keyboard_interrupt_clears_screen0TestReader.test_keyboard_interrupt_clears_screen   s    ),	-4  %d	%0@A%d	%0@A%f)G2DE	
 "&)*44Y?HH
	7    	?OOC.23NNS/3$$V$>	?s   $B7 7A:D54D5c                n   R p\         P                  ! V4      w  r#V P                  W!4       V P                  V^4       Rp\         P                  ! V4      w  r#V P                  VR4       V P                  V^4       Rp\         P                  ! V4      w  r#V P                  VR4       V P                  V^4       Rp\         P                  ! V4      w  r#V P                  W!4       V P                  V^4       Rp\         P                  ! V4      w  r#V P                  VR4       V P                  V^4       R# )r3   z[0;32m>>> [0mz[0;32m>>> [0mu   樂>> u   [0;32m樂>[0m> u   [0;32m樂>[0m> N)r   process_promptrf   )r   r6   promptls   &   r#   test_prompt_lengthTestReader.test_prompt_length  s   ))#.	%A &))#.	!89A 6))#.	!89A ))#.	%A 8))#.	!:;Ar&   c                *   R \         /pRp\         P                  ! \        V4      \        RR\	        R4      R7      \        RR\	        R4      R7      .\        R4      4      p\
        P                  ! \        \        P                  ! V4      P                  R7      p\        W4R7      w  rVVP                  pV P                  \        V4      ^4       V P                  V^ ,          V R24       V P                  V^,          P                  4       R	4       R
# )rU   
itertools.rM   r   r   rP   r   r   r@   zitertools.accumulate(N)rU   rV   r   r   rW   r   r   r   r   r   r   r   r   rf   r   rstrip)r   r   rH   r    completing_readerr!   r"   actuals   &       r#   %test_completions_updated_on_key_press0TestReader.test_completions_updated_on_key_press/  s     ),	4  %d	%0@A%d	%0@A
 3
 &--*44Y?HH
 &fO	Va(tfAJ/))+-DEr&   c           
     R   R \         /pRp\         P                  ! \        V4      \        RR\	        R4      R7      .\        R4      4      p\
        P                  ! \        \        P                  ! V4      P                  R7      p\        W4R7      w  rVV P                  WR R24       R	# )
rU   r   rM   r   r   rP   r   r   r@   N)rU   rV   r   r   rW   r   r   r   r   r   r   r   r   )r   r   rH   r    r   r!   r"   s   &      r#    test_key_press_on_tab_press_once+TestReader.test_key_press_on_tab_press_onceG  s     ),	4 %d	%0@A 3
 &--*44Y?HH
 &fO	  64r&   c                    \        . 4      p\        V4      p. Vn        V P                  VP	                  4       R4       R# )r   N)r   r   )r   r   
screeninforf   pos2xy)r   r   r!   s   &  r#   test_pos2xy_with_no_columns&TestReader.test_pos2xy_with_no_columnsZ  s4    !"%(&1r&   c                    R p\        V4      p\        V4      w  r4VP                  ^^ 4       V P                  VP                  ^4       R# )u   # non ‌ printing characterNrd   rG   s   &    r#   )test_setpos_from_xy_for_non_printing_char4TestReader.test_setpos_from_xy_for_non_printing_chara  sA    0%%f-	a#Q'r&    N)__name__
__module____qualname____firstlineno__r$   r*   r/   rA   rI   rX   r\   ra   rh   rk   rp   rs   r{   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classdict__s   @r#   r   r      sw     :
<
F

>
4/2:())(	-()T8 7B>F05&2( (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# )TestReaderInColorii  c           
        \        R 4      p\        R4      pVP                  ! RRR/\        B p\        V4      p\	        V4      w  rVV P                  WQRR7       V P                  WS4       V P                  VP                  R4       V P                  VP                  R4       RP                  ! R/ \        B pVP                  ! RRV/\        B p\        P                  ! \        V4      \        RR	\        R
4      R7      .^,          \        R4      4      p	\	        V	4      w  rVV P                  WX4       V P                  VP                  ^4       V P                  VP                  R4       R# )aL              import re, sys
            def funct(case: str = sys.platform) -> None:
                match = re.search(
                    "(me)",
                    '''
                    Come on
                      Come on now
                        You know that it's time to emerge
                    ''',
                )
                match case:
                    case "emscripten": print("on the web")
                    case "ios" | "android":
                        print("on the phone")
                    case _: print('arms around', match.group(1))
            a              {k}import{z} re{o},{z} sys
            {a}{k}def{z} {d}funct{z}{o}({z}case{o}:{z} {b}str{z} {o}={z} sys{o}.{z}platform{o}){z} {o}->{z} {k}None{z}{o}:{z}
                match {o}={z} re{o}.{z}search{o}({z}
                    {s}"(me)"{z}{o},{z}
                    {s}'''{z}
            {s}        Come on{z}
            {s}          Come on now{z}
            {s}            You know that it's time to emerge{z}
            {s}        '''{z}{o},{z}
                {o}){z}
                {K}match{z} case{o}:{z}
                    {K}case{z} {s}"emscripten"{z}{o}:{z} {b}print{z}{o}({z}{s}"on the web"{z}{o}){z}
                    {K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z}
                        {b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
                    {K}case{z} {K}_{z}{o}:{z} {b}print{z}{o}({z}{s}'arms around'{z}{o},{z} match{o}.{z}group{o}({z}{n}1{z}{o}){z}{o}){z}
            r   r4   TrD   i  z{k}async{z} rM   rx   ry   rP   zasync Nr   )r      )      )r   formatcolorsr   r   r   rf   rg   cxyrU   rV   r   rW   )
r   rH   r   expected_syncr    r!   r"   	async_msgexpected_asyncmore_eventss
   &         r#   test_syntax_highlighting_basic0TestReaderInColor.test_syntax_highlighting_basick  s=   
& 
& !7"77%%f-	  T :  7S)W-"))3F3	!?9??oo4 u4Yy-ABCbH8$

 &k2	  8R(V,r&   c                    \        R 4      p\        R4      P                  ! R/ \        B p\        V4      p\	        V4      w  rEV P                  WARR7       V P                  WB4       R# )zI            def unfinished_function(arg: str = "still typing
            zs            {k}def{z} {d}unfinished_function{z}{o}({z}arg{o}:{z} {b}str{z} {o}={z} {s}"still typing{z}
            TrD   Nr   r   r   r   r   r   r   r   rH   r   r    r!   r"   s   &     r#   5test_syntax_highlighting_incomplete_string_first_lineGTestReaderInColor.test_syntax_highlighting_incomplete_string_first_line  sv    

 
 &	  	
  %%f-	  T :  2r&   c                    \        R 4      p\        R4      P                  ! R/ \        B p\        V4      p\	        V4      w  rEV P                  WARR7       V P                  WB4       R# )zZ            def unfinished_function(
                arg: str = "still typing
            z            {k}def{z} {d}unfinished_function{z}{o}({z}
                arg{o}:{z} {b}str{z} {o}={z} {s}"still typing{z}
            TrD   Nr   r   r   s   &     r#   7test_syntax_highlighting_incomplete_string_another_lineITestReaderInColor.test_syntax_highlighting_incomplete_string_another_line  sv    
 

 & 
   %%f-	  T :  2r&   c                    \        R 4      p\        R4      P                  ! R/ \        B p\        V4      p\	        V4      w  rEV P                  WARR7       V P                  WB4       R# )zr            def unfinished_function():
                '''Still writing
                the docstring
            z            {k}def{z} {d}unfinished_function{z}{o}({z}{o}){z}{o}:{z}
                {s}'''Still writing{z}
            {s}    the docstring{z}
            TrD   Nr   r   r   s   &     r#   4test_syntax_highlighting_incomplete_multiline_stringFTestReaderInColor.test_syntax_highlighting_incomplete_multiline_string  v    
 
 &    %%f-	  T :  2r&   c                    \        R 4      p\        R4      P                  ! R	RRRR/\        B p\        V4      p\	        V4      w  rEV P                  WARR7       V P                  WB4       R# )
z            def unfinished_function():
                var = f"Single-quote but {
                1
                +
                1
                } multi-line!
            a              {k}def{z} {d}unfinished_function{z}{o}({z}{o}){z}{o}:{z}
                var {o}={z} {s}f"{z}{s}Single-quote but {z}{o}{OB}{z}
                {n}1{z}
                {o}+{z}
                {n}1{z}
                {o}{CB}{z}{s} multi-line!{z}
            OB{CB}TrD   Nr   r   r   s   &     r#   +test_syntax_highlighting_incomplete_fstring=TestReaderInColor.test_syntax_highlighting_incomplete_fstring  s    	
 	
 &	 	+ 	+  	+ $*	+  %%f-	  T :  2r&   c                    \        R 4      p\        R4      P                  ! R/ \        B p\        V4      p\	        V4      w  rEV P                  WARR7       V P                  WB4       R# )z_            def unfinished_function():
                var = 1
               oops
            z            {k}def{z} {d}unfinished_function{z}{o}({z}{o}){z}{o}:{z}
                var {o}={z} {n}1{z}
               oops
            TrD   Nr   r   r   s   &     r#   *test_syntax_highlighting_indentation_error<TestReaderInColor.test_syntax_highlighting_indentation_error  r   r&   c                    \        R 4      p\        R4      P                  ! R	/ \        B P                  RR4      P                  RR4      p\	        V4      p\        V4      w  rEV P                  WARR7       RV n        V P                  WB4       R# )
z            f"{{"
            f"}}"
            f"a{{b"
            f"a}}b"
            f"a{{b}}c"
            t"a{{b}}c"
            f"{{{0}}}"
            f"{ {0} }"
            a              {s}f"{z}{s}<<{z}{s}"{z}
            {s}f"{z}{s}>>{z}{s}"{z}
            {s}f"{z}{s}a<<{z}{s}b{z}{s}"{z}
            {s}f"{z}{s}a>>{z}{s}b{z}{s}"{z}
            {s}f"{z}{s}a<<{z}{s}b>>{z}{s}c{z}{s}"{z}
            {s}t"{z}{s}a<<{z}{s}b>>{z}{s}c{z}{s}"{z}
            {s}f"{z}{s}<<{z}{o}<{z}{n}0{z}{o}>{z}{s}>>{z}{s}"{z}
            {s}f"{z}{o}<{z} {o}<{z}{n}0{z}{o}>{z} {o}>{z}{s}"{z}
            <r   >r   TrD   Nr   )r   r   r   replacer   r   r   maxDiffr   s   &     r#   <test_syntax_highlighting_literal_brace_in_fstring_or_tstringNTestReaderInColor.test_syntax_highlighting_literal_brace_in_fstring_or_tstring
  s    	
 	
 &   #73,WWS#-> 	  %%f-	  T :  2r&   c                    R p\        V4      p\        V4      w  r4V P                  VRRR7       V P                  VRP                  ! R/ \        B 4       R# )u   flag = "🏳️‍🌈"u   flag = "🏳️\u200d🌈"TrD   u&   flag {o}={z} {s}"🏳️\u200d🌈"{z}Nr   )r   r   r   r   r   rG   s   &    r#   test_control_characters)TestReaderInColor.test_control_characters)  sS    (%%f-	  )Fd S  )R)Y)Y)c\b)cdr&   )r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @r#   r   r   i  s5     9-v3 3$3(343(3>e er&   r   )!rU   r   r   textwrapr   unittestr   unittest.mockr   test.supportr   r   supportr   r	   r
   r   r   r   _pyrepl.consoler   _pyrepl.readerr   	_colorizer   	overridessyntaxitemsgetlowerr   r   r   )kvs   00r#   <module>r     s         # S D 5 4 ! ! # c>3/	8E8L8L8R8R8T	U8T)--Q4::<
(!
+8T	U  Q(!8 Q(  Q(f
 De(( De Deq
 
Vs   42C