+
    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
t
^ RIt
^ RIHtHtHtHtHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ RIHt ^ RIt^ RIHtH t  ]PB                  ! 4       '       g   ]
PD                  ! R4      h]R 4       t# ! R	 R
4      t$ ! R R]
PJ                  4      t& ! R R]
PJ                  4      t']! 4       ]
PP                  ! ]R4       ! R R]
PJ                  4      4       4       t)R t*]
PP                  ! ]PB                  ! 4       '       * R4      ]
PP                  ! ]PV                  R8g  ;'       d'    ]PV                  R8g  ;'       d    ]PV                  R8g  R4      ]
PP                  ! ]PV                  R8H  ;'       d    ]*! 4       '       * R4      ]]! 4        ! R R]
PJ                  4      4       4       4       4       4       t,]-R8X  d   ]
P\                  ! 4        R# R# )    N)closingcontextmanagerredirect_stdoutredirect_stderr	ExitStack)is_wasicpython_onlyforce_colorrequires_subprocessSHORT_TIMEOUTsubTests)TESTFNunlink)List)
_PdbServer
_PdbClientzremote debugging is disabledc              #     "   T ;_uu_ 4         V x   RRR4       R#    T P                  4        h ; i  + '       g   i     R# ; i5i)zGContext manager killing the subprocess if a Python exception is raised.N)kill)procs   &+/usr/lib/python3.14/test/test_remote_pdb.pykill_on_errorr      s9      
	J 
	IIK 
s$   A4
A14A		Ac                      a  ] tR t^%t o RtR tV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 lt	V 3R lR lt
V 3R lR ltRtV tR# )MockSocketFilezJMock socket file for testing _PdbServer without actual socket connections.c                "    . V n         . V n        R # Ninput_queueoutput_bufferselfs   &r   __init__MockSocketFile.__init__(   s        c                $   < V ^8  d   QhRS[ RR/#    datareturnNbytes)format__classdict__s   "r   __annotate__MockSocketFile.__annotate__,   s     ( (% (D (r#   c                <    V P                   P                  V4       R# )zSimulate write to socket.N)r   appendr    r'   s   &&r   writeMockSocketFile.write,   s    !!$'r#   c                   < V ^8  d   QhRR/# r&   r(   N )r+   r,   s   "r   r-   r.   0         t r#   c                    R# )zNo-op flush implementation.Nr6   r   s   &r   flushMockSocketFile.flush0       r#   c                    < V ^8  d   QhRS[ /# r&   r(   r)   )r+   r,   s   "r   r-   r.   4   s     ' '% 'r#   c                `    V P                   '       g   R# V P                   P                  ^ 4      # )z*Read a line from the prepared input queue.r#   )r   popr   s   &r   readlineMockSocketFile.readline4   s(    ##A&&r#   c                   < V ^8  d   QhRR/# r5   r6   )r+   r,   s   "r   r-   r.   :   r7   r#   c                    R# )zClose the mock socket file.Nr6   r   s   &r   closeMockSocketFile.close:   r;   r#   c                $   < V ^8  d   QhRS[ RR/# r%   )dict)r+   r,   s   "r   r-   r.   >   s     C Cd Ct Cr#   c                    V P                   P                  \        P                  ! V4      P	                  4       R,           4       R# )z,Add input that will be returned by readline.   
N)r   r0   jsondumpsencoder1   s   &&r   	add_inputMockSocketFile.add_input>   s-    

4 0 7 7 9E ABr#   c                0   < V ^8  d   QhRS[ S[,          /# r=   )r   rG   )r+   r,   s   "r   r-   r.   B   s     
 
DJ 
r#   c                \   . pV P                    Fv  p\        V\        4      '       g   K  VP                  R4      '       g   K4   VP	                  \
        P                  ! VP                  4       P                  4       4      4       Kx  	  . V n         V#   \
        P                   d     K  i ; i)z;Get the output that was written by the object being tested.rI   )
r   
isinstancer*   endswithr0   rJ   loadsdecodestripJSONDecodeError)r    resultsr'   s   &  r   
get_outputMockSocketFile.get_outputB   s    &&D$&&4==+?+?NN4::dkkm.A.A.C#DE '   ++ s   ABB+*B+r   N)__name__
__module____qualname____firstlineno____doc__r!   r2   r9   r@   rD   rM   rX   __static_attributes____classdictcell__r,   s   @r   r   r   %   sK     T ( ( ' ' C C
 
r#   r   c                     a  ] tR t^Ot o RtRRRRRRRRRRR	RR
RRRRRRR/
R ltR tR tR tR t	R t
]P                  ! ]P                  P                  ^8  R4      ]! RRR/R3RR/R3RR/R3.4      R 4       4       t]P                  ! ]P                  P                  ^8  R4      ]! RRR/R3RR/R 3RR/R!3.4      R" 4       4       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R0 t R1 t!R2 t"R3 t#R4 t$R5 t%R6 t&R7t'V t(R# )8PdbClientTestCasezTests for the _PdbClient class.simulate_send_failureF#simulate_sigint_during_stdout_writeuse_interrupt_socketexpected_outgoingNexpected_outgoing_signalsexpected_completionsexpected_exceptionexpected_stdout expected_stdout_substringexpected_statec          	     
  a$a%a&a' Vf   . pVf   . pVf   . pVf   / pVP                  RR4       V UUu. uF  w  rVR8X  g   K  VNK  	  pppV UUu. uF  w  rVR8X  g   K  VR,          NK  	  pppR V 4       o&. o%V$V%V&3R lp\        4       ;_uu_ 4       p\        P                  ! 4       w  ppVP	                  \        V4      4       VP	                  \        V4      4       \        P                  P                  VR7      pVP                  R	P                  R
 V 4       4      4       VP                  \        P                  4       V'       dN   \        P                  P                  \        R4      R7      Vn	        VP                  \        P                  4       \        P                   ! 4       pV'       d   VP"                  o'V'3R lpVVn        VP	                  \        P                  P%                  RVR7      4      pVP	                  \'        V4      4       V'       d2   \        P                  P                  \        P                  R7      pR pM@R pVP	                  \        P                  P%                  R\(        P*                  R7      4      p\-        RVVR7      o$Ve5   VR,          pVR,          pVP	                  V P/                  VVR7      4       S$P1                  4        R R R 4       XP                  P2                   Uu. uF  pVP4                  ^ ,          NK  	  ppV F  pVP7                  R4      '       d   K  Q h	  V Uu. uF  p\8        P:                  ! V4      NK  	  ppV P=                  VV4       V P=                  S%V4       V
'       d*   V	'       g"   V P?                  V
XPA                  4       4       M V P=                  XPA                  4       V	4       XPC                  V Uu. uF"  p\        P                  PE                  V4      NK$  	  up4       V Uu/ uF  pV\G        S$V4      bK  	  ppV P=                  VV4       V'       d_   XP                  PH                   U u. uF=  p \J        PL                  ! \N        PQ                  V P4                  ^ ,          4      4      NK?  	  p!p MaXf   Q h. p!VPH                   FI  p V P4                  w  p"p#V P=                  V"R4       V!PS                  \J        PL                  ! V#4      4       KK  	  V P=                  V!V4       R # u uppi u uppi   + '       g   i     ELV; iu upi u upi u upi u upi u up i )Nwrite_failedFserveruserpromptc              3   <   "   T F  w  rVR 8X  g   K  Vx  K  	  R# 5i)rr   Nr6   ).0sourcems   &  r   	<genexpr>,PdbClientTestCase.do_test.<locals>.<genexpr>n   s     FIFVv5Eaas   
c                 f  < \        S
R 4      pVf   \        hVP                  R4      ;p'       Ed/   \        P                  P                  4       pVR,          VP                  n        VR,          VP                  n        VR,          VP                  n        \        P                  P                  V4       \        P                  P                  P                  \        P                  RV/4      ;_uu_ 4        \        P                   ! 4        FE  pVR,          VR,          VR,           pSP#                  WT4      pVf    MS	P%                  V4       KG  	  R R R 4       VR,          p\'        V\(        4      '       d   Vh\'        V\*        4      '       d   V# V! 4       #   + '       g   i     LP; i)Ncompletion_requestlinebegidxendidxr@   input)nextEOFErrorgetunittestmockMockget_line_bufferreturn_value
get_begidx
get_endidxsealpatchrG   sysmodules	itertoolscountcompleter0   rQ   BaseExceptionstr)rs   messagereqreadline_mockparamprefix
completionreplyclientcompletions
input_iters   &       r   
mock_input-PdbClientTestCase.do_test.<locals>.mock_inputq   sC   :t,Gkk"677s7 ( 2 2 4=@[--:8;H((58;H((5""=1]]((--ckkJ;VWW!*!2!$VS]S]!K%+__V%C
%-!#**:6 "3 X G$E%//%%%7N XWs   9AF  F0	)wrapsr#   c              3      "   T FH  p\        V\        4      '       d   TM#\        P                  ! V4      P	                  4       R ,           x  KJ  	  R# 5i)rI   N)rQ   r*   rJ   rK   rL   )ru   rw   s   & r   rx   ry      s>      % %Q..QDJJqM4H4H4JeSS%s   AAzsendall failedside_effectc                 \   < \         P                  ! \         P                  4       S! V 4      # r   signalraise_signalSIGINT)sorig_stdout_writes   &r   sigint_stdout_write6PdbClientTestCase.do_test.<locals>.sigint_stdout_write   s     ''6,Q//r#   z	pdb.input)speczos.killi90  )pidserver_socketinterrupt_sock	exceptionmsg)r   rI   )*
setdefaultr   socket
socketpairenter_contextr   r   r   r   sendalljoinshutdownSHUT_WROSErrorSHUT_RDioStringIOr2   r   r   osr   r   assertRaisescmdloop
mock_callsargsrR   rJ   rS   assertEqualassertIngetvalueassert_has_callscallgetattrcall_args_listr   Signalsint
from_bytesr0   )(r    incomingrd   re   rf   rg   rh   ri   rj   rk   rm   rn   rv   rw   messagespromptsr   stackclient_sockserver_sockstdoutr   
input_mockr   	mock_killr   r   	sent_msgsactual_outgoingpkactual_stater   outgoing_signalsr   signumr   r   r   r   s(   &$$$$$$$$$$$                        @@@@r   do_testPdbClientTestCase.do_testR   s    $ "$,(*%'#% !N!!.%8'/Fx)&6X3EAAxF08M96Ff<L;1X;;MFF
	4 [[E'-'8'8':$K 45 45"--,,;,?K %    0$&.mm&8&8 '(8 9 '9 '# $$V^^4[[]F2$*LL!0  3,,##KZ#HJ  78#!)!3!3!3!G 	!%!//MM''	'@	  )-F "-.{;	(/##D$5$5iS$5$IJNNs v -8,?,?,J,JK,JSSXXa[[,J	KC<<&&&& 6?@is4::c?i@*;<&:;$_MM3V__5FGV__.@##G$LGqX]]%7%7%:G$LM7EF~!761--~F~6 +22AA AD s~~diil;<A   
 (((!!00"iiV  e, ''v(>? 1 	)+DEm GM> [[v L A %MF sJ   T/T/T5"T5D$T;<D2T;UU7(U*U4AU#;U	c                4    . p. pV P                  VVR7       R# )zDTest the behavior when the remote closes the connection immediately.)r   rg   Nr   )r    r   rg   s   &  r   .test_remote_immediately_closing_the_connection@PdbClientTestCase.test_remote_immediately_closing_the_connection   s$    / 	 	
r#   c                H    RR. RO/3.pV P                  V. R0 Rm/R7       R# )z'Test handling the command_list message.rq   command_listpdb_commandsr   rg   rn   N)helplistcontinue>   r   r   r   r   r    r   s   & r   test_handling_command_list,PdbClientTestCase.test_handling_command_list   s=     (DEF
 	  < 	 	
r#   c                @    RRRRR/3.pV P                  V. RR7       R# )z1Test handling a message payload with type='info'.rq   r   Some message or other
typeinfor   rg   rk   Nr   r   s   & r   test_handling_info_message,PdbClientTestCase.test_handling_info_message   s9     	#<ffMN
 	 5 	 	
r#   c                @    RRRRR/3.pV P                  V. RR7       R# )	z2Test handling a message payload with type='error'.rq   r   zSome message or other.r   errorz*** Some message or other.
r   Nr   r   s   & r   test_handling_error_message-PdbClientTestCase.test_handling_error_message  s9     	#;VWMN
 	 : 	 	
r#   c                @    RRRRR/3.pV P                  V. RR7       R# )z:Test handling a message payload with an unrecognized type.rq   r   zSome message.
r   unknownr   Nr   r   s   & r   test_handling_other_message-PdbClientTestCase.test_handling_other_message  s9     	#4fiHI
 	 - 	 	
r#   zHelp not available for -OOzhelp_request,expected_substringr   llzUsage: ll | longlistztype help <topic>pdbz>>> import pdbc                8    RV3.pV P                  V. VR7       R# )z3Test handling help requests when help is available.rq   r   rg   rm   Nr   r    help_requestexpected_substringr   s   &&& r   !test_handling_help_when_available3PdbClientTestCase.test_handling_help_when_available  /     |$
 	 &8 	 	
r#   z	Needs -OOzNo help for 'll'zUndocumented commandszNo help for 'pdb'c                8    RV3.pV P                  V. VR7       R# )z7Test handling help requests when help is not available.rq   r   Nr   r   s   &&& r   %test_handling_help_when_not_available7PdbClientTestCase.test_handling_help_when_not_available1  r  r#   c                    RRR./3RRRRR/3RRRR	R
/3RRRR	R/3RRRRR/3RRRR	R/3RRRRR/3RRRR	R/3RRRRR/3RRRR	R/3RRRR	R/3.pV P                  VRR/RR/RR/RR/.RR/R7       R# )z(Test responding to pdb's normal prompts.rq   r   brs   (Pdb) stater   rr   r   lst [...   0 ]rl   b [z! b [b ]r   	lst [
0 ]z!b [
b ]r   Nr   r   s   & r   test_handling_pdb_prompts+PdbClientTestCase.test_handling_pdb_promptsH  s    ./(GU;<h'7;<h'59:(GU;<h'267(GU;<h'59:(GU;<h'7;<h'59:
 	,'"% +&	 $U+ 	 		
r#   c                    RRR./3RRRRR/3RRRR	R
/3RRRR	R/3RRRRR/3RRRR	R/3RRRRR/3RRRR	R/3RRRR	R/3.	pV P                  VRR/RR/RR/.RR/R7       R# )z/Test responding to pdb's interact mode prompts.rq   r   r
  rs   >>> r  interactrr   r   r  ... r  rl   r  r  r   r  zb [
b ]r   Nr   r   s   & r   test_handling_interact_prompts0PdbClientTestCase.test_handling_interact_promptsb  s     ./&':>?h9:h78&':>?h45&':>?h78h78

 	,'"*%
 $Z0 	 	
r#   c                v    RRRRR/3RRRRR/3RRRRR	/3RRR
RR/3.pV P                  VRR/.RRR/R7       R# )=Test re-prompting after a SyntaxError in a Python expression.rq   rs   r  r  r   rr   r   z lst [r  r   0 ]r   
lst [
 0 ]z*** IndentationErrorr   rg   rm   rn   Nr   r   s   & r   %test_retry_pdb_prompt_on_syntax_error7PdbClientTestCase.test_retry_pdb_prompt_on_syntax_errory  s     (GU;<h'8<=h'7;<h'6:;	
 	-( '=#U+ 	 	
r#   c                v    RRRRR/3RRRRR/3RRRRR	/3RRR
RR/3.pV P                  VRR/.RRR/R7       R# )r  rq   rs   r  r  r  rr   r   z!lst [r  r  r  r   r  z*** SyntaxErrorr  Nr   r   s   & r   *test_retry_interact_prompt_on_syntax_error<PdbClientTestCase.test_retry_interact_prompt_on_syntax_error  s     &':>?h:;h9:h89	
 	-( '8#Z0 	 	
r#   c                    RRRRR/3RRRRR/3RRRRR/3RRRRR	/3RRRRR/3RRRRR
/3RRRRR/3RRRRR/3.pV P                  VRR/RR	/RR
/RR/.RR/R7       R# )z<Test fallback to "dumb" single-line mode for unknown states.rq   rs   Do it? r  confirmrr   r   z! [z
echo hellorl   zecho goodbyer   dumbr   Nr   r   s   & r   &test_handling_unrecognized_prompt_type8PdbClientTestCase.test_handling_unrecognized_prompt_type  s     )Wi@Ah	7E:;)Wi@Ah	7LAB)Wi@Ah	7B78)Wi@Ah	7NCD	
 	% ,'".)	 $V, 	 		
r#   c                Z    RRRRR/3RRRRR /3.pV P                  VR	R
/.RR/R7       R# )z.Test signaling when a prompt gets interrupted.rq   rs   r  r  r   rr   r   c                  J    \         P                  ! \         P                  4      # r   r   r6   r#   r   <lambda>9PdbClientTestCase.test_sigint_at_prompt.<locals>.<lambda>      V%8%8%Gr#   r   INTr   Nr   r   s   & r   test_sigint_at_prompt'PdbClientTestCase.test_sigint_at_prompt  sa     (GU;<hG	
 	5! $U+ 	 	
r#   c                h    RRRRR/3RRRRR/3RRR	RR
 /3.pV P                  VRR/.RR/R7       R# )z;Test signaling when a continuation prompt gets interrupted.rq   rs   r  r  r   rr   r   if True:r  c                  J    \         P                  ! \         P                  4      # r   r   r6   r#   r   r-  FPdbClientTestCase.test_sigint_at_continuation_prompt.<locals>.<lambda>  r/  r#   r   r0  r   Nr   r   s   & r   "test_sigint_at_continuation_prompt4PdbClientTestCase.test_sigint_at_continuation_prompt  sr     (GU;<h':>?hG

 	5! $U+ 	 	
r#   c                    RRRRR/3.pR
 FL  pV P                  VR7      ;_uu_ 4        V P                  VRV. \        P                  .RR7       R	R	R	4       KN  	  R	#   + '       g   i     Kc  ; i)z9Test siginaling when sys.stdout.write() gets interrupted.rq   r   r   r   r   T)rf   )r   re   rf   rg   rh   rk   N)FT)subTestr   r   r   )r    r   rf   s   &  r   test_sigint_when_writing*PdbClientTestCase.test_sigint_when_writing  sx     	#<ffMN
 %2 3GHH%8<)=&(/5}}o$=   IH %2HHHs   'AA/c                h    RRRRR/3RRRR\        4       /3.pV P                  VRR	/.RR/R
7       R# )z.Test signaling when a prompt gets an EOFError.rq   rs   r  r  r   rr   r   r   EOFr   N)r   r   r   s   & r   test_eof_at_prompt$PdbClientTestCase.test_eof_at_prompt  s\     (GU;<h'8:>?
 	5! $U+ 	 	
r#   c                Z    RRR/3RRRRR/3.pV P                  V. R\        R	R
/R7       R# )z3Test failing after getting an unrecognized payload.rq   montypythonr   r   r   r   r   r   z+Unrecognized payload b'{"monty": "python"}')r   rg   rj   N)r   RuntimeErrorr   s   & r   test_unrecognized_json_message0PdbClientTestCase.test_unrecognized_json_message  sS     *+	#<ffMN
 	 \F  	 	
r#   c                d    R
RRRRR/3.pV P                  V. RP                  RR.4      R7       R	# )z1Test continuing after getting a non JSON payload.rq   r   	Somethingr   r   
z'*** Invalid JSON from remote: b'spam\n'r   N)rq   s   spam)r   r   r   s   & r   0test_continuing_after_getting_a_non_json_payloadBPdbClientTestCase.test_continuing_after_getting_a_non_json_payload  sO      	;?@
 	  II> 	 		
r#   c                j    RRRRR/3RRRR\        4       /3.pV P                  VRR	/.R
RR
/R7       R# )z<Test terminating if write fails due to a half closed socket.rq   rs   r  r  r   rr   r   r   r0  Trp   )r   rg   rd   rn   N)KeyboardInterruptr   r   s   & r   test_write_failing$PdbClientTestCase.test_write_failing  s]     (GU;<h'3D3FGH
 	 (%01"&*D1	 	 	
r#   c                    RRRRR/3RRRRRR	R
^R^	/RR/3RRRR./3.pV P                  VRRRRRR
^R^//RR/.RR.RR/R7       R# )z2Test requesting tab completions at a (Pdb) prompt.rq   rs   r  r  r   rr   r{   r|   z	    mod._r}   r~   r   print(
    mod.__name__)r   rZ   __file__r   text_zmod._r   r   rg   ri   rn   Nr   r   s   & r   test_completion_in_pdb_state.PdbClientTestCase.test_completion_in_pdb_state&  s     (GU;<h( ! !+
 8 
J'?@A
  	  ! !	! 56
 #-j!9#U+ 	 	
r#   c                    RRRRR/3RRRRR/3RRR	R
RRR^R^/RR/3RR. RO/3RRR	RR/3.pV P                  VRRRRRR^R^//RR/.. RORR/R7       R# )z?Test requesting tab completions at a (Pdb) continuation prompt.rq   rs   r  r  r   rr   r   r4  r  r{   r|   z    br}   r~   z
    bool()r   rl   r   rS  r
  z! br   zif True:
    bool()
rU  N)binboolr*   r   r   s   & r   &test_multiline_completion_in_pdb_state8PdbClientTestCase.test_multiline_completion_in_pdb_stateJ  s     (GU;<h':>?h( ! !+
 \ '?@Ah'267!
$ 	  ! !	! 23
 ":#U+ 	 	
r#   c                    RRRRR/3RRRRRR	R
^R^
/RR/3RRRR./3.pV P                  VRRRRRR
^R^//RR/.RR.RR/R7       R# )z0Test requesting tab completions at a >>> prompt.rq   rs   r  r  r  rr   r{   r|   z
    mod.__r}   r~   r   rQ  r   rZ   rR  r   rS  __zmod.__r   rU  Nr   r   s   & r   !test_completion_in_interact_state3PdbClientTestCase.test_completion_in_interact_statep  s     &':>?f( ! "+
 8 
J'?@A
  	  ! !	! 56
 #-j!9#Z0 	 	
r#   c                t    RRR./3RRRRR/3RRRR	R
RR^ R^/RR/3.pV P                  VRR/.RR/R7       R# )z:Test requesting tab completions at an unrecognized prompt.rq   r   r   rs   r&  r  r'  rr   r{   r|   rT  r}   r~   r   rZ   r   r(  r   Nr   r   s   & r    test_completion_in_unknown_state2PdbClientTestCase.test_completion_in_unknown_state  s     ./)Wi@Ai( ! !+
 Z
  	*% $V, 	 	
r#   c                    RRRRR/3RRRRRR	R
^ R^/RR/3.pV P                  VRRR	RR	R
^ R^//RR/.R. RRRR/R7       R# )z?Test failing to write to the socket to request tab completions.rq   rs   r  r  r  rr   r{   r|   xyr}   r~   r   xyzr   rS  r   Trp   )r   rg   rd   ri   rn   Nr   r   s   & r   $test_write_failure_during_completion6PdbClientTestCase.test_write_failure_during_completion  s     &':>?f( ! !+
 U
 	  ! !	! % 
 #'!##ZF 	 	
r#   c                    RRRRR/3RRRRRR	R
^ R^/RR/3.pV P                  VRRR	RR	R
^ R^//RR/.. RR/R7       R# )z5Test failing to read tab completions from the socket.rq   rs   r  r  r  rr   r{   r|   re  r}   r~   r   rf  r   rS  r   rU  Nr   r   s   & r   #test_read_failure_during_completion5PdbClientTestCase.test_read_failure_during_completion  s     &':>?f( ! !+
 U
 	  ! !	! % 
 "$#Z0 	 	
r#   c                    RRRRR/3RRRRRR	R
^ R^/RR/3RRRRRR/3.pV P                  VRRR	RR	R
^ R^//RR/.R. RR/R7       R# )z9Test receiving invalid JSON when getting tab completions.rq   rs   r  r  r  rr   r{   r|   re  r}   r~   r   rf  r   rS  r   z *** json.decoder.JSONDecodeError)r   rg   rm   ri   rn   N)rq   s   {"completions": r   r   s   & r   +test_reading_invalid_json_during_completion=PdbClientTestCase.test_reading_invalid_json_during_completion  s     &':>?f( ! !+
 U ,h78
" 	  ! !	! % 
 'I!##Z0 	 	
r#   c                    RRRRR/3RRRRRR	R
^ R^/RR/3R/ 3RRRRR/3.pV P                  VRRR	RR	R
^ R^//RR/.R. RR/R7       R# )zATest receiving an empty JSON object when getting tab completions.rq   rs   r  r  r  rr   r{   r|   re  r}   r~   r   rf  r   rS  r   z;*** RuntimeError: Failed to get valid completions. Got: {}
)r   rg   rk   ri   rn   Nr   r   s   & r   )test_reading_empty_json_during_completion;PdbClientTestCase.test_reading_empty_json_during_completion  s     &':>?f( ! !+
 U rNh78
" 	  ! !	! % 
 "$#Z0% 	 	
r#   r6   ))rZ   r[   r\   r]   r^   r   r   r   r   r   r   r   skipIfr   flagsoptimizer   r  r  r  r  r   r#  r)  r1  r7  r;  r?  rE  rJ  rN  rV  r[  r_  rb  rg  rj  rm  rp  r_   r`   ra   s   @r   rc   rc   O   s    )OF $	OF
 -2OF #OF OF #'OF "OF  OF OF #%OF OFb

	
	
	
 __SYY''1,.JK) d^34b\./e_./	

	

 L	
 __SYY''!+[9) d^/0b\23e_12	

	

 :	

4
.
"
"
.
(
* 


"
"
H$
L!
F
4!
F 
D#
J&
 &
r#   rc   c                   `   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V tR# )RemotePdbTestCasei@  zTests for the _PdbServer class.c                   \        4       V n        \        V P                  4      V n        R V P                  n        RV P                  n        R^R^RR^d//V n        R^R^/V n        \        P                  P                  4       pV P                  Vn        V P                  Vn        ^*Vn        \        P                  P                  4       Vn        RVP                  n        R	VP                  n        WP                  n        R # )
NFar
  __pdb_convenience_variablesxcdztest_file.pytest_function)r   sockfiler   r   botframequittingtest_globalstest_localsr   r   r   	f_globalsf_localsf_linenof_codeco_filenameco_namecurframe)r    
frame_infos   & r   setUpRemotePdbTestCase.setUpC  s    &(dmm, !! !!S!-JSRUJWC+ ]]'')
#00
"..
 
$MM..0
(6
%$3
!&r#   c                P   V P                   P                  R4       V P                   P                  R4       V P                  P	                  4       pV P                  \        V4      ^4       V P                  V^ ,          RRRR/4       V P                  V^,          RRRR/4       R# )	z1Test message and error methods send correct JSON.zTest messagez
Test errorr   zTest message
r   r   r   N)r   r   r   r~  rX   r   lenr    outputss   & r   test_message_and_error(RemotePdbTestCase.test_message_and_errorZ  s    (|$--**,Wq)i1A66%RSivw%OPr#   c                    V P                   P                  RR/4       V P                  P                  4       pV P	                  VR4       R# )z&Test reading commands from the socket.r   r   N)r~  rM   r   _read_replyr   )r    cmds   & r   test_read_command#RemotePdbTestCase.test_read_commandd  s?     	& 12 hh""$f%r#   c                    RV P                   n        V P                  \        4      ;_uu_ 4        V P                   P	                  4        RRR4       R#   + '       g   i     R# ; i)zTest reading EOF command.TN)r   _write_failedr   r   r  r   s   &r   test_read_command_EOF'RemotePdbTestCase.test_read_command_EOFm  s@     "&x((HH  " )(((s   AA%	c                @   \         P                  P                  P                  V P                  RRR.R7      ;_uu_ 4        V P
                  P                  RRRRRR	^ R
^//4       V P
                  P                  RR/4       V P                  P                  4       pV P
                  P                  4       pV P                  \        V4      ^4       V P                  V^ ,          RRR./4       V P                  VR4       RRR4       R#   + '       g   i     R# ; i)z"Test handling completion requests.completenamesr   clearr   r   rS  r{  r|   r}   r~   r   r   r   N)r   r   r   objectr   r~  rM   r  rX   r   r  )r    r  r  s   &  r   test_completion!RemotePdbTestCase.test_completiont  s    ]]  ''/5?4I ( K K MM##CCaa	%  MM##Wf$56 ((&&(C mm..0GS\1-WQZ-*g9N)OP S&)3K K K Ks   CDD	c                    V P                   P                  R4       V P                  P                  4       pV P	                  \        V4      ^4       V P	                  V^ ,          RR/4       R# )z)Test that do_help sends the help message.breakr   N)r   do_helpr~  rX   r   r  r  s   & r   test_do_helpRemotePdbTestCase.test_do_help  sS    !--**,Wq)fg%67r#   c                8   V P                   P                  R4       V P                  V P                   P                  4       V P	                  V P                   P                  \
        4       \        P                  P                  P                  V P                   R4      ;_uu_ 4       pV P                   P                  R4       VP                  4        V P                   P                  R4       VP                  4        RRR4       R#   + '       g   i     R# ; i)z*Test interaction mode setup and execution.rl   
_error_exczprint('test')zif:N)r   do_interactassertIsNotNone_interact_stateassertIsInstancerG   r   r   r   r  _run_in_python_replassert_not_calledassert_called_once)r    
mock_errors   & r   test_interact_mode$RemotePdbTestCase.test_interact_mode  s     	R  	TXX556dhh66= ]]  '',??:HH((9((* HH((/))+ @???s   'ADD	c           	     d   \         P                  P                  P                  V P                  R4      ;_uu_ 4        V P
                  P                  RR/4       V P
                  P                  RR/4       V P
                  P                  RR/4       V P
                  P                  RR/4       V P
                  P                  RR/4       V P                  P                  4        V P
                  P                  4       pV P                  R	V^ ,          4       V P                  V^,          R
RRR/4       V P                  V^,          R
RRR/4       V P                  V^,          R
RRR/4       V P                  V^,          R
RRR/4       V P                  V^,          R
RRR/4       V P                  V^,          RRRR/4       V P                  \        V4      ^4       V P                  V P                  P                  ^,          RR.4       RRR4       R#   + '       g   i     R# ; i)z%Test registering breakpoint commands.get_bpbynumberr   z
commands 1silentzprint('hi')endr   r>  r   rs   r  r  r   z(com) commandsr   rI  r   r   _pdbcmd_silence_frame_statusN)r   r   r   r  r   r~  rM   r   rX   r   r   r  r  r  s   & r   test_registering_commands+RemotePdbTestCase.test_registering_commands  s    ]]  ''2BCCMM##Wl$;<MM##Wh$78MM##Wm$<=MM##We$45MM##Xu$56 HHmm..0GMM.'!*5WQZ(Hgu)MNWQZ(Hgz)RSWQZ(Hgz)RSWQZ(Hgz)RSWQZ(Hgu)MNWQZ)T66)JKS\1-!!!$/?+ DCCCs   GHH/	c                V   \         P                  P                  P                  V P                  R4      ;_uu_ 4       pV P
                  P                  4        VP                  4        V P                  V P
                  P                  4       RRR4       R#   + '       g   i     R# ; i)zTest the detach method.rD   N)
r   r   r   r  r~  r   detachr  assertFalser  )r    
mock_closes   & r   test_detachRemotePdbTestCase.test_detach  sg    ]]  ''w??:HHOO))+TXX../ @???s   ABB(	c                &   \         P                  P                  P                  V P                  RRR7      ;_uu_ 4       pRR.V P                  n        V P                  P                  RR/4       V P                  P                  RR/4       R	 pW!n        RV P                  n	        V P                  P                  4        V P                  VP                  ^4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  P                  4       pV Uu. uF  pR
V9   g   K  VNK  	  ppV P                  \        V4      ^4       RRR4       R# u upi   + '       g   i     R# ; i)z,Test the command loop with various commands.onecmdFr  r   r   r   r   quitc                     V R 8H  # )r  r6   )r|   s   &r   r   3RemotePdbTestCase.test_cmdloop.<locals>.side_effect  s    v~%r#   rs   N)r   r   r   r  r   cmdqueuer~  rM   r   r  r   r   
call_countassert_any_callrX   r  )r    mock_onecmdr   r  or   s   &     r   test_cmdloopRemotePdbTestCase.test_cmdloop  sH    ]]  ''('OOS^!' 0DHH MM##Wf$56 MM##Wf$56&&1# !&DHHHH [33Q7''/''/''/''/ mm..0G");'QX]qq'G;S\1-; PO8 <9 POOs$   D E??	E:E:E?:E??F	)r   r~  r  r  N)rZ   r[   r\   r]   r^   r  r  r  r  r  r  r  r  r  r  r_   r`   ra   s   @r   rv  rv  @  s@     )'.Q&#*<8,$:0 .  .r#   rv  z!WASI does not support TCP socketsc                   v   a  ] tR tRt o RtR tRR l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# )PdbConnectTestCasei  zCTests for the _connect mechanism using direct socket communication.c                .   \         P                   ! \         P                  \         P                  4      V n        V P                  P	                  R4       V P                  P                  ^4       V P                  P                  4       ^,          V n        R# 	127.0.0.1N)r  r   )r   AF_INETSOCK_STREAMr   bindlistengetsocknameportr   s   &r   r  PdbConnectTestCase.setUp  sc    !==9K9KL./"$$00215	r#   Nc                   Vf%   \         P                  ! RV P                   R24      p\        R,           V n        \        V P                  R4      ;_uu_ 4       pVP                  V4       R R R 4       R #   + '       g   i     R # ; i)Na  
                import pdb
                import sys
                import time

                def foo():
                    x = 42
                    return bar()

                def bar():
                    return 42

                def connect_to_debugger():
                    # Create a frame to debug
                    def dummy_function():
                        x = 42
                        # Call connect to establish connection
                        # with the test server
                        frame = sys._getframe()  # Get the current frame
                        pdb._connect(
                            host='127.0.0.1',
                            port=a  ,
                            frame=frame,
                            commands="",
                            version=pdb._PdbServer.protocol_version(),
                            signal_raising_thread=False,
                            colorize=False,
                        )
                        return x  # This line won't be reached in debugging

                    return dummy_function()

                result = connect_to_debugger()
                foo()
                print(f"Function returned: {result}")
                _connect_test.pywtextwrapdedentr  r   script_pathopenr2   r    scriptfs   && r   _create_script!PdbConnectTestCase._create_script  so    >__"* #')) -+#$FL "$66$""C((AGGFO )(((s   A55B	c                    V P                   P                  4         \        V P                  4       R #   \         d     R # i ; ir   )r   rD   r   r  r   r   s   &r   tearDownPdbConnectTestCase.tearDown,  s9     	4##$ 		   3 AAc                n   \         P                  ! \        P                  V P                  .\         P
                  \         P
                  RR7      pV P                  P                  4       w  r#VP                  R4      pV P                  VP                  4       V P                  VP                  4       W3# )z9Helper to start subprocess and get connected client file.Tr   stderrrS  rwb)
subprocessPopenr   
executabler  PIPEr   acceptmakefile
addCleanuprD   )r    processr   rT  client_files   &    r   _connect_and_get_client_file/PdbConnectTestCase._connect_and_get_client_file3  s     ""^^T--.????	
 ))002!**51))*))*##r#   c                    . p VP                  4       pV'       g    V# \        P                  ! VP                  4       4      pVP	                  V4       RV9   g   KZ   V# )z3Helper to read messages until a prompt is received.rs   )r@   rJ   rS   rT   r0   )r    r  r   r'   r   s   &&   r   _read_until_prompt%PdbConnectTestCase._read_until_promptE  sV    '')D
 	 **T[[]+COOC 3r#   c                    VP                  \        P                  ! RV/4      P                  4       R,           4       VP	                  4        R# )z)Helper to send a command to the debugger.r   rI   N)r2   rJ   rK   rL   r9   )r    r  commands   &&&r   _send_command PdbConnectTestCase._send_commandR  s8    $**gw%78??AEIJr#   c                   V P                  4        V P                  4       w  r\        V4      ;_uu_ 4        VP                  4       p\        P
                  ! VP                  4       4      pV P                  RV4       V P                  RVR,          4       VP                  4       p\        P
                  ! VP                  4       4      pV P                  RV4       VP                  4       p\        P
                  ! VP                  4       4      pV P                  RV4       V P                  VR,          R4       V P                  VR4       V P                  V4      pV Uu. uF%  pRV9   g   K  RVR,          9   g   K  VR,          NK'  	  p	p\        V	4      p
R	R.p\        WR
R7       F  w  rV P                  W4       K  	  V P                  V
R4       V P                  VR4       VP                  \        R7      w  rV P                  RV4       V P                  VP                   ^ 4       RRR4       R# u upi   + '       g   i     R# ; i)z@Test connecting to a remote debugger and sending basic commands.r   zpdb._connectr   rs   r  r   btconnect_to_debuggerz<module>T)strictz,Should have received stack trace informationr{  timeoutFunction returned: 42N)r  r  r   r@   rJ   rS   rT   r   r   r  r  rZ  zip
assertTruecommunicater   
returncode)r    r  r  r'   initial_datar   prompt_datar   r   text_msggot_stack_infoexpected_stacksr   r   rT  s   &              r   test_connect_and_basic_commands2PdbConnectTestCase.test_connect_and_basic_commandsW  s    #@@B7##'')D::dkkm4LMM)\2MM.,y*AB '')D::dkkm4LMM.,7 '')D**T[[]3KMM(K0[159 {D1 ..{;H 3; U(3 C' ',AS^,S 'I(H U!(^N %O
 "/DI
e) J OON,Z[ {C0  ++M+BIF MM16:W//3_ $#2U3 $##s+   D,H>"	H90H9 H9B"H>9H>>I	c                   V P                  4        V P                  4       w  r\        V4      ;_uu_ 4        V P                  V4       V P	                  VR4       V P                  V4      p\        R V 4       4      pV P                  RV4       V P	                  VR4       V P                  V4      p\        R V 4       4      pV P                  RV4       V P	                  VR4       V P                  V4      p\        R \        V4       4       4      pV P                  R	V4       V P                  R
V4       V P	                  VR4       V P                  V4      p\        R \        V4       4       4      pV P                  RV4       V P	                  VR4       VP                  \        R7      w  rV P                  RV4       V P                  VP                  ^ 4       RRR4       R#   + '       g   i     R# ; i)z%Test setting and hitting breakpoints.z	break barc              3   F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5ir   Nr6   ru   r   s   & r   rx   6PdbConnectTestCase.test_breakpoints.<locals>.<genexpr>  s     QHS	S@P.#i..H   	!!
Breakpointr{  c              3   F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5ir  r6   r  s   & r   rx   r    s     RXccAQ>3y>>Xr  bar()r
  c              3   F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5ir  r6   r  s   & r   rx   r    s"     ]6HsIY\L\NC	NN6Hr  z1   breakpointzbreakpoint already hit 1 timezclear 1c              3   F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5ir  r6   r  s   & r   rx   r    s"     ^7IYZ]M]^S^^7Ir  zDeleted breakpointr  r  N)r  r  r   r  r  r   r   reversedr
  r   r   r  )
r    r  r  r   bp_msghit_msglist_msg	clear_msgr   rT  s
   &         r   test_breakpoints#PdbConnectTestCase.test_breakpoints  s   #@@B7####K0 {K8..{;HQHQQFMM,/ {C0..{;H RXRRGMM'7+ {C0..{;H]hx6H]]HMM*H5MM98D {I6..{;H^x7I^^IMM.	: {C0++M+BIFMM16:W//3I $###s   F*G**G;	c                2   \         P                  ! RV P                   R24      pV P                  VR7       V P	                  4       w  r#V P
                  P                  4       w  rEV P                  VP                  4       \        V4      ;_uu_ 4        V P                  V4       V P                  VR4       VP                  P                  4       ;p'       d   VP                  R4      '       g   K;   VP                  \         P"                  P%                  4       4       V P                  V4      pV Uu. uF  pRV9   g   K  VR,          NK  	  p	pV	 Uu. uF  pRV9   g   K  VNK  	  p
pV P'                  \)        V
4      ^ 4       V P                  VR4       V P                  VR4       VP+                  \,        R	7      w  rV P/                  R
V4       V P1                  VP2                  ^ 4       RRR4       R# u upi u upi   + '       g   i     R# ; i)z5Test that sending keyboard interrupt breaks into pdb.a  
            import time
            import sys
            import socket
            import pdb
            def bar():
                frame = sys._getframe()  # Get the current frame
                pdb._connect(
                    host='127.0.0.1',
                    port=af  ,
                    frame=frame,
                    commands="",
                    version=pdb._PdbServer.protocol_version(),
                    signal_raising_thread=True,
                    colorize=False,
                )
                print("Connected to debugger")
                iterations = 50
                while iterations > 0:
                    print("Iteration", iterations, flush=True)
                    time.sleep(0.2)
                    iterations -= 1
                return 42

            if __name__ == "__main__":
                print("Function returned:", bar())
            r  r{  	Iterationr   r  ziterations = 0r  r  N)r  r  r  r  r  r   r  r  rD   r   r  r  r   r@   
startswithr   r   r   to_bytesassertGreaterr  r
  r   r   r   r  )r    r  r  r  signal_sockrT  r|   r   r   interrupt_msgsexpected_msgr   s   &           r   test_keyboard_interrupt*PdbConnectTestCase.test_keyboard_interrupt  s     	& )) %" 6 	6*#@@B ))002))*7####K0 {C0
 "..1133$3??;//  6 6 89..{;H 9AUIQTDTnc)nnNU+9L>CW^CC>LLs<0!4 {,<={C0++M+BIFMM16:W//39 $#& VL) $##sE   AHH2AH5	G;G;H	H $H *BH;
HH	c                   V P                  4        V P                  4       w  r\        V4      ;_uu_ 4        V P                  V4       VP	                  \
        P                  ! RR/4      P                  4       R,           4       VP                  4        VP                  \        R7      w  r4V P                  RV4       V P                  VP                  ^ 4       V P                  VR4       RRR4       R#   + '       g   i     R# ; i)z1Test that EOF signal properly exits the debugger.r   r>  rI   r  r  rl   N)r  r  r   r  r2   rJ   rK   rL   r9   r
  r   r   r   r  )r    r  r  r   r  s   &    r   test_handle_eof"PdbConnectTestCase.test_handle_eof  s    #@@B7####K0 djj(E):;BBDuLM %000GNF MM16:W//3VR( $###s   B6C66D	c                   \         P                  ! RV P                   R24      pV P                  VR7       V P	                  4       w  r#\        V4      ;_uu_ 4        VP                  4       p\        P                  ! VP                  4       4      pV P                  RV4       V P                  VR,          R4       V P                  RVR,          4       V P                  RVR,          4       VP                  \        R	7      w  rgV P                  R
V4       V P                  RV4       V P                  VP                  ^ 4       RRR4       R#   + '       g   i     R# ; i)z?Test that incompatible protocol versions are properly detected.a  
            import sys
            import pdb

            def run_test():
                frame = sys._getframe()

                # Use a fake version number that's definitely incompatible
                fake_version = 0x01010101 # A fake version that doesn't match any real Python version

                # Connect with the wrong version
                pdb._connect(
                    host='127.0.0.1',
                    port=a  ,
                    frame=frame,
                    commands="",
                    version=fake_version,
                    signal_raising_thread=False,
                    colorize=False,
                )

                # This should print if the debugger detaches correctly
                print("Debugger properly detected version mismatch")
                return True

            if __name__ == "__main__":
                print("Test result:", run_test())
            r&  r   r   r   incompatiblezprotocol versionr  zTest result: Truez+Debugger properly detected version mismatchN)r  r  r  r  r  r   r@   rJ   rS   rT   r   r   r
  r   r  )r    r  r  r  r'   r   r   r  s   &       r   test_protocol_version(PdbConnectTestCase.test_protocol_version  s"     & )) %" 8 	6*#@@B7##'')Djj/GMM)W-WV_g6MM.')*<=MM,gi.@A %000GNF MM-v6MMGPW//3! $###s   C*EE!	c                   V P                  4        V P                  4       w  r\        V4      ;_uu_ 4        V P                  V4       . ROpV F  pV P	                  W$4       VP                  4       p\        P                  ! VP                  4       4      pV P                  RV4       VR8X  d   V P                  VR,          R4       M0VP                  4       ^,          pV P                  VR,          V4       V P                  V4       K  	  V P	                  VR4       VP                  \        R7      w  rV P                  RV4       V P                  VP                  ^ 4       RRR4       R#   + '       g   i     R# ; i)zATest that the help system properly sends help text to the client.r   rl   r{  r  r  N)r   z
help breakzhelp continuezhelp pdb)r  r  r   r  r  r@   rJ   rS   rT   r   r   splitr
  r   r  )
r    r  r  help_commandsr  r'   r   r  r   r  s
   &         r   test_help_system#PdbConnectTestCase.test_help_systemC  s6   #@@B7####K0 PM$"";4 #++-**T[[]3fg.&=$$WV_b9 "iik!nG$$WV_g> ''4% %* {C0$000GNFMM16:W//3A $###s   D0E00F	c                <   V P                  4        V P                  4       w  r\        V4      ;_uu_ 4        V P                  V4       . ROpV F%  pV P	                  W$4       V P                  V4       K'  	  V P	                  VR4       V P                  V4      p\        R V 4       4      pV P                  RV4       V P	                  VR4       V P                  V4       V P	                  VR4       V P                  V4      p\        R V 4       4      pV P                  RV4       V P	                  VR4       VP                  \        R	7      w  rxV P                  R
V4       V P                  VP                  ^ 4       RRR4       R#   + '       g   i     R# ; i)zCTest that multi-line commands work properly over remote connection.ztest_func()c              3   F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5ir  r6   r  s   & r   rx   >PdbConnectTestCase.test_multi_line_commands.<locals>.<genexpr>        UIQTDTnc)nnr  42zobj = TestClass()zobj.get_value()c              3   F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5ir  r6   r  s   & r   rx   r>    r?  r  100r{  r  r  N)zdef test_func():
    return 42zfor i in range(3):
    print(i)z#if True:
    x = 42
else:
    x = 0zUtry:
    result = 10/2
    print(result)
except ZeroDivisionError:
    print('Error')ztclass TestClass:
    def __init__(self):
        self.value = 100
    def get_value(self):
        return self.value)r  r  r   r  r  r   r   r
  r   r   r  )	r    r  r  multi_line_commandsr  r   
result_msgr   r  s	   &        r   test_multi_line_commands+PdbConnectTestCase.test_multi_line_commandsj  sj   #@@B7####K0#" +"";4''4 +
 {M:..{;H UUUJMM$
+ {,?@##K0 {,=>..{;H UUUJMM%, {C0$000GNFMM16:W//3g $###s   E
F

F	)r  r  r   r   )rZ   r[   r\   r]   r^   r  r  r  r  r  r  r  r#  r.  r1  r5  r:  rE  r_   r`   ra   s   @r   r  r    sX      N6+Z$$
44l(4TA4F)*24h%4N84 84r#   r  c                  <    R p  ^ RI Hp  V #   \         d     T # i ; i)FPROCESS_VM_READV_SUPPORTED)_remote_debuggingrI  ImportErrorrH  s    r   _supports_remote_attachingrL    s2    !&@ &%  %%s    zRemote debugging is not enableddarwinlinuxwin32z*Test only runs on Linux, Windows and MacOSz2Testing on Linux requires process_vm_readv supportc                   H   a  ] tR tRt o R tR
R ltR tR tR tR t	R	t
V tR# )PdbAttachTestCasei  c                N   \         P                   ! \         P                  \         P                  4      V n        V P                  P	                  R4       V P                  P                  ^4       V P                  P                  4       ^,          V n        V P                  4        R# r  )	r   r  r  sockr  r  r  r  r  r   s   &r   r  PdbAttachTestCase.setUp  sf    MM&..&2D2DE			'(		II))+A.	r#   Nc                
   \         P                  ! R V P                   R24      p\        R,           V n        \        V P                  R4      ;_uu_ 4       pVP                  V4       RRR4       R#   + '       g   i     R# ; i)a`  
            import socket
            import time

            def foo():
                return bar()

            def bar():
                return baz()

            def baz():
                x = 1
                # Trigger attach
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                sock.connect(('127.0.0.1', a  ))
                sock.close()
                count = 0
                while x == 1 and count < 100:
                    count += 1
                    time.sleep(0.1)
                return x

            result = foo()
            print(f"Function returned: {result}")
            r  r  Nr  r  s   && r   r   PdbAttachTestCase._create_script  si    , -1II; 
7
8 "$66$""C((AGGFO )(((s   A11B	c                    V P                   P                  4         \        V P                  4       R #   \         d     R # i ; ir   )rS  rD   r   r  r   r   s   &r   r  PdbAttachTestCase.tearDown  s5    			4##$ 		r  c                   \         P                  ! \        P                  V P                  .\         P
                  \         P
                  R R7      pV P                  VP                  P                  4       V P                  VP                  P                  4       V P                  P                  ^
4       V P                  P                  4       w  r4VP                  4        \        P                  ! V4      p\        P                  ! 4       p\        P                  ! 4       pV P                  VP                  4       V P                  VP                  4       V P                  VP                  4       V P                  VP                  4       \         P"                  P%                  RV4      ;_uu_ 4        \'        V4      ;_uu_ 4        \)        V4      ;_uu_ 4        \         P"                  P%                  RRR\+        VP,                  4      .4      ;_uu_ 4        \         P"                  P%                  R\.        R7      ;_uu_ 4         \0        P2                  ! 4        R	R	R	4       R	R	R	4       R	R	R	4       R	R	R	4       R	R	R	4       VP                  4        VP                  P7                  4       pVP                  P7                  4       pVP8                  ^ 8w  d(   \;        R
4       \;        RV 24       \;        RV 24       V P=                  VP8                  ^ 4       RRVP?                  4       RVP?                  4       /RRVRV//#   \.         d    T P5                  R4        EL	i ; i  + '       g   i     EL; i  + '       g   i     EL"; i  + '       g   i     EL.; i  + '       g   i     EL:; i  + '       g   i     ELF; i)Tr  z	sys.stdinzsys.argvr   z-pz"pdb.exit_with_permission_help_textr   z-Insufficient permissions for remote executionNzserver failedzserver stdout:
zserver stderr:
r   r   r  rq   ) r  r  r   r  r  r  r  r   rD   r  rS  
settimeoutr  r   r   waitr   r   r   r   r   r   r   PermissionErrorr   mainskipTestreadr  printr   r   )	r    client_stdinr  connrT  client_stdoutclient_stderrserver_stdoutserver_stderrs	   &&       r   do_integration_test%PdbAttachTestCase.do_integration_test  s   ""^^T--.????	
 	,,-,,- 			R ))""$

{{<0**+++,++,% MM\::M**M**MM
UD#gkk:J,KLLMM4/    O
 M + + ; 	++-++-"/"$]O45$]O45++Q/-002-002 --	
 		
 # OMNO   MLL +** +** ;::s   6N?
N+	?N.NM/M"N*N2N+	:N?M,(M/+M,,M//N :	NN	NN("	N+	+N<6	N??O	c                   \        R 4      ;_uu_ 4        V P                  R4      pRRR4       V P                  XR,          R,          R4       V P                  VR,          R,          R4       V P                  VR,          R,          R4       V P                  R	VR,          R,          4       V P	                  R
VR,          R,          4       R#   + '       g   i     L; i)Fll
x=42
Nr   r  rl   rq   r   Function returned: 42
while x == 1)r
   rg  r   r   assertNotInr    outputs   & r   %test_attach_to_process_without_colors7PdbAttachTestCase.test_attach_to_process_without_colors$  s    --l;F  )(3R8)(3R8)(35NOnfX&6x&@A!1(!;<  s   CC 	c           	     2   \        R 4      ;_uu_ 4        V P                  R4      pRRR4       V P                  XR,          R,          R4       V P                  VR,          R,          R4       V P                  VR,          R,          R4       V P                  R	VR,          R,          4       V P	                  R
VR,          R,          4       V P                  R
\
        P                  ! RRVR,          R,          4      4       R#   + '       g   i     L; i)Trj  Nr   r  rl   rq   r   rk  rm  rl  z[^m]*m)r
   rg  r   r   rn  resubro  s   & r   "test_attach_to_process_with_colors4PdbAttachTestCase.test_attach_to_process_with_colors.  s    --l;F )(3R8)(3R8)(35NOffX.x89)9()CDnbff\2vh?OPX?Y&Z[ s   DD	)r  r  rS  r   )rZ   r[   r\   r]   r  r  r  rg  rq  rv  r_   r`   ra   s   @r   rQ  rQ    s,      D9
v=	\ 	\r#   rQ  __main__)/r   r   rJ   r   rt  r   r   r  r   r  r   unittest.mock
contextlibr   r   r   r   r   test.supportr   r	   r
   r   r   r   test.support.os_helperr   r   typingr   r   r   r   is_remote_debug_enabledSkipTestr   r   TestCaserc   rv  rr  r  rL  platformrQ  rZ   r]  r6   r#   r   <module>r     s   	   	 	    
    [ [ i i 1  
 & ""$$


:
;;  ' 'Tn
)) n
bp.)) p.f 	=>m4** m4 ? m4`& 
S00224UV	)aacllg.Eaa#,,ZaJa@B	(MM1K1M-MHJ@\)) @\  JB W@\D zMMO r#   