
    0hh*                       S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKJrJr  S SKJr  S SKJr  S SKJrJr  S SKJr  S SKJrJr  S SKJr  \R8                  (       + r " S	 S
\5      rS r S r!S r"S r#S r$S r%S r&S r'S r(S r)S r*S r+S r,S r-S r.S r/\R`                  Rb                  (       d  S r2S r3S r4S r5S r6S  r7S! r8S" r9S# r:S$ r;S% r<S& r=S' r>\R~                  " S(5      r@\A" S)\@R                  5        S* rCS+ rDS, rES- rFS. rGS/ rHS0 rI\(       d  S1 rJS2 rKS3 rL\(       d  S4 rMS5 rN\(       d  S6 rOS7 rPS8 rQS9 rRS: rSS; rTS< rUS= rVS> rWS? rXS@ rYSA rZSB r[SC r\SD r]SE r^SF r_SG r`SH raSI rbSJ rc\R                  " 5        " SK SL\R                  5      5       rf " SM SN\R                  5      rg\R                  " 5        " SO SP\R                  5      5       rhSQ ri\jSR:X  a  \R                  " 5         gg)S    N)	ExitStackredirect_stdout)StringIO)support)force_not_colorized	os_helper)import_module)run_pty	FakeInput)patchc                   &    \ rS rSrS rS rS rSrg)PdbTestInput   c                     Xl         g N)input)selfr   s     6/opt/python-3.13.8/usr/lib/python3.13/test/test_pdb.py__init__PdbTestInput.__init__   s    
    c                     [         R                  U l        [        U R                  5      [         l        [        [         S5      (       a  [         R                  " 5       U l        g S U l        g )Ngettrace)sysstdin
real_stdinr   r   hasattrr   
orig_tracer   s    r   	__enter__PdbTestInput.__enter__!   s<    ))djj)	,3C,D,D#,,.$r   c                     U R                   [        l        U R                  (       a!  [        R                  " U R                  5        g g r   )r   r   r   r   settrace)r   excs     r   __exit__PdbTestInput.__exit__&   s)    OO	??LL) r   )r   r   r   N)__name__
__module____qualname____firstlineno__r   r    r%   __static_attributes__ r   r   r   r      s    O
*r   r   c                      g r   r,   r,   r   r   test_pdb_displayhookr.   ,       r   c                      g r   r,   r,   r   r   test_pdb_basic_commandsr1   H   r/   r   c                  @    SS K n U R                  R                  5         g )Nr   )bdb
BreakpointclearBreakpoints)r3   s    r   reset_Breakpointr6      s    NN##%r   c                      g r   r,   r,   r   r   test_pdb_breakpoint_commandsr8      r/   r   c                      g r   r,   r,   r   r   -test_pdb_breakpoint_on_annotated_function_defr:   i  r/   r   c                      g r   r,   r,   r   r   !test_pdb_breakpoint_with_filenamer<     r/   r   c                      g r   r,   r,   r   r   :test_pdb_breakpoints_preserved_across_interactive_sessionsr>     r/   r   c                      g r   r,   r,   r   r   test_pdb_pp_repr_excr@     r/   r   c                      g r   r,   r,   r   r   test_pdb_empty_linerB     r/   r   c                      g r   r,   r,   r   r   
do_nothingrD   2  s    r   c                      [        S5        g )N*   )printr,   r   r   do_somethingrH   5  s	    	"Ir   c                      g r   r,   r,   r   r   test_list_commandsrJ   8  r/   r   c                      g r   r,   r,   r   r   test_pdb_whatis_commandrL     r/   r   c                      g r   r,   r,   r   r   test_pdb_display_commandrN     r/   r   c                      g r   r,   r,   r   r   test_pdb_alias_commandrP     r/   r   c                      g r   r,   r,   r   r   test_pdb_where_commandrR   L  r/   r   c                      g r   r,   r,   r   r   test_pdb_interact_commandrT     r/   r   c                      g r   r,   r,   r   r   test_convenience_variablesrV     r/   r   c                      g r   r,   r,   r   r   test_post_mortem_chainedrX     r/   r   c                      g r   r,   r,   r   r   !test_post_mortem_cause_no_contextrZ   k  r/   r   c                      g r   r,   r,   r   r   %test_post_mortem_context_of_the_causer\     r/   r   c                      g r   r,   r,   r   r   test_post_mortem_from_noner^     r/   r   c                      g r   r,   r,   r   r   test_post_mortem_from_no_stackr`     r/   r   c                      g r   r,   r,   r   r    test_post_mortem_single_no_stackrb   7  r/   r   c                      g r   r,   r,   r   r   test_post_mortem_complexrd   L  r/   r   c                      g r   r,   r,   r   r   test_post_mortemrf     r/   r   c                      g r   r,   r,   r   r   !test_pdb_return_to_different_filerh     r/   r   c                      g r   r,   r,   r   r   test_pdb_skip_modulesrj   '  r/   r   c                      g r   r,   r,   r   r   test_pdb_invalid_argrl   A  r/   r   module_to_skipz6def foo_pony(callback): x = 1; callback(); return Nonec                      g r   r,   r,   r   r   #test_pdb_skip_modules_with_callbackro   b  r/   r   c                      g r   r,   r,   r   r    test_pdb_continue_in_bottomframerq     r/   r   c                 N    [        [        R                  " SSS9U 5      " U5        g )NTF)nosigintreadrc)getattrpdbPdb)methodargs     r   
pdb_invokerz     s    CGGT%0&9#>r   c                      g r   r,   r,   r   r   $test_pdb_run_with_incorrect_argumentr|     r/   r   c                      g r   r,   r,   r   r   test_pdb_run_with_code_objectr~     r/   r   c                      g r   r,   r,   r   r   &test_next_until_return_at_return_eventr     r/   r   c                      g r   r,   r,   r   r   #test_pdb_next_command_for_generatorr   *  r/   r   c                      g r   r,   r,   r   r   #test_pdb_next_command_for_coroutiner   j  r/   r   c                      g r   r,   r,   r   r   "test_pdb_next_command_for_asyncgenr     r/   r   c                      g r   r,   r,   r   r   %test_pdb_return_command_for_generatorr     r/   r   c                      g r   r,   r,   r   r   %test_pdb_return_command_for_coroutiner   #  r/   r   c                      g r   r,   r,   r   r   $test_pdb_until_command_for_generatorr   Q  r/   r   c                      g r   r,   r,   r   r   $test_pdb_until_command_for_coroutiner     r/   r   c                      g r   r,   r,   r   r   +test_pdb_next_command_in_generator_for_loopr     r/   r   c                      g r   r,   r,   r   r   !test_pdb_next_command_subiteratorr     r/   r   c                      g r   r,   r,   r   r   test_pdb_multiline_statementr   	  r/   r   c                      g r   r,   r,   r   r   test_pdb_closurer   4	  r/   r   c                      g r   r,   r,   r   r    test_pdb_show_attribute_and_itemr   s	  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_20766r   	  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_43318r   	  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_91742r   	  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_94215r   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_101673r   H
  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_103225r   d
  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_101517r   }
  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_108976r   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_127321r   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_80731r   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_ambiguous_statementsr   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_f_trace_linesr   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_frame_refleakr   
  r/   r   c                      g r   r,   r,   r   r   test_pdb_function_breakr   0  r/   r   c                      g r   r,   r,   r   r   test_pdb_issue_gh_65052r   Y  r/   r   c                      \ rS rSrS r\R                  " \R                  R                  S5        S?S j5       r
     S@S jrS rS rS	 rS
 rS rS rS rS rS rS rS rS rS r\S 5       r\S 5       rS rS rS rS rS r S r!S r"S r#S r$S r%S  r&S! r'S" r(S# r)S$ r*S% r+S& r,S' r-S( r.S) r/S* r0S+ r1S, r2S- r3S. r4S/ r5S0 r6S1 r7S2 r8S3 r9S4 r:S5 r;\<Rz                  S6 5       r>S7 r?S8 r@S9 rAS: rBS; rCS< rDS= rES>rFg)APdbTestCasei  c                 L    [         R                  " [         R                  5        g r   r   unlinkTESTFNr   s    r   tearDownPdbTestCase.tearDown      ))*r   z'PYTHONSAFEPATH changes default sys.pathNc           	         U R                  [        R                  S5        [        R                  SS/U-   nUb  [
        R                  U-  nO[
        R                  n[        R                  " U[        R                  [        R                  [        R                  0 UESS0ES9 nUR                  [        R                  U5      5      u  pS S S 5        [        W[        5      (       a  [        R                  U5      OUn[        W	[        5      (       a  [        R                  U	5      OU	n	U R!                  WR"                  USU SU	 35        X4$ ! , (       d  f       N= f)	N__pycache__-mrv   PYTHONIOENCODINGutf-8stdoutr   stderrenvzUnexpected return code
stdout: z	
stderr: )
addCleanupr   rmtreer   
executableosenviron
subprocessPopenPIPEcommunicatestrencode
isinstancebytesdecodeassertEqual
returncode)
r   pdb_argscommandsexpected_returncode	extra_envcmdr   procr   r   s
             r   _run_pdbPdbTestCase._run_pdb  s   
 		((-8~~tU+h6 **y(C**C! oo!::0':
 !--cjj.BCNF
 *4FE)B)Bf%)3FE)B)Bf%OO.vhjI	

 ~
 
s   &'E
E!c                    Sn[        US5       n	U	R                  [        R                  " U5      5        S S S 5        UbZ  [        SS5       n	U	R                  [        R                  " U5      5        S S S 5        U R	                  [
        R                  S5        U R	                  [
        R                  U5        S n
U(       a   [        R                  R                  SS 5      n
 Uc  / nU R                  U/U-   X#U5      u  pU
b  U
[        R                  S'   X4$ ! , (       d  f       N= f! , (       d  f       N= f! U
b  U
[        R                  S'   f f = f)Nmain.pyw.pdbrcHOME)openwritetextwrapdedentr   r   r   r   r   popr   )r   scriptr   r   r   script_argspdbrcremove_homefilenamefhomesaver   r   s                r   run_pdb_scriptPdbTestCase.run_pdb_script  s    (C AGGHOOF+, ! h$./ %OOI,,h7	(((3zz~~fd3H	." !]]H:+CXdmnNF#%-

6"~' !  %$ #%-

6" $s#   &D&D,$D= 
D),
D:=Ec                 @   SU l         [        R                  " U R                   5        U R                   S-   nU R                   S-   n[        R                  " U R                   5        [        US5       n S S S 5        [        US5       nUR                  [        R                  " U5      5        S S S 5        U R                  [        R                  U R                   5        U R                  SU R                   /U5      $ ! , (       d  f       N= f! , (       d  f       Ng= f)Nt_main/__main__.py/__init__.pyr   r   )module_namer   r   r   mkdirr   r   r   r   r   r   )r   r   r   	main_file	init_filer   s         r   run_pdb_modulePdbTestCase.run_pdb_module  s    #))*$$~5	$$~5	
!!")S!Q ")S!QGGHOOF+, "	(($*:*:;}}dD$4$45x@@ "!!!s   2C>&D>
D
Dc                 <   [        [        R                  S5       nUR                  U5        S S S 5        U(       d  S OUS   [        R                  US   4nU R	                  U[
        R                  " U[        R                  5      5        g ! , (       d  f       Nf= f)Nwbr      )r   r   r   r   r   rv   find_function)r   file_content	func_nameexpectedr   s        r   _assert_find_function!PdbTestCase._assert_find_function  sx    )""D)QGGL! *  (4QK))8A;.8c''	93C3CD	F *)s   B
Bc                 *    U R                  SSS 5        g )Nr   foo)r  r   s    r   test_find_function_empty_file)PdbTestCase.test_find_function_empty_file  s    ""3t4r   c                 F    U R                  SR                  5       SS5        g )Nu@   def foo():
    pass

def bœr():
    pass

def quux():
    pass
   bœr)r     r  r   r   s    r   test_find_function_found$PdbTestCase.test_find_function_found  s$    ""	 FH	
r   c                 H    U R                  SR                  S5      SS5        g )NuV   # coding: iso-8859-15
def foo():
    pass

def bœr():
    pass

def quux():
    pass
ziso-8859-15r  )r     r  r   s    r   -test_find_function_found_with_encoding_cookie9PdbTestCase.test_find_function_found_with_encoding_cookie  s'    ""
 F=	
r   c                 h    U R                  [        R                  SR                  5       -   SS5        g )Nu   def bœr():
    pass
r  )r     )r  codecsBOM_UTF8r   r   s    r   !test_find_function_found_with_bom-PdbTestCase.test_find_function_found_with_bom  s2    ""OO  FH 	
r   c                 V    SnSnU R                  X5      u  p4U R                  SU5        g )NzJ
            import __main__
            print(__main__.__spec__)
        continueNoner   assertInr   r   r   r   _s        r   	test_specPdbTestCase.test_spec  s0    
 ''9	ff%r   c                     [         R                  " S5      R                  5       nU R                  USS5        U R                  USS5        U R                  USS5        U R                  USS	5        g )
Na              def foo(): pass

            def bar():
                pass  # line 4

            def baz():
                # comment
                pass  # line 8

            def mul():
                # code on multiple lines
                code = compile(   # line 12
                    'def f()',
                    '<string>',
                    'exec',
                )
        r  )r  r   bar)r%     baz)r'     mul)r)     )r   r   r   r  )r   codes     r   (test_find_function_first_executable_line4PdbTestCase.test_find_function_first_executable_line  sk       " VX# 	& 	""4
;""4
;""4
;""4<r   c                    [        [        R                  S5       nUR                  S5        S S S 5        [        R
                  SS[        R                  /n[        R                  " U[        R                  [        R                  [        R                  S9nU R                  UR                  R                  5        UR                  S5      u  pEU R                  SUS5        g ! , (       d  f       N= f)	Nr   s   print("testing my pdb")
r   rv   )r   r   r   s   quit
s   SyntaxErrorz0Got a syntax error running test script under PDB)r   r   r   r   r   r   r   r   r   r   r   closer   assertNotInr   r   r   r   r   r   s         r   test_issue7964PdbTestCase.test_issue79645  s    )""D)QGG23 *~~tUI,<,<=??//??
 	))*)))4K	M *)s   C$$
C2c                     SnSnU R                  X5      u  p4U=(       d    SU=(       d    S-   nU R                  SUS5        U R                  SUS5        g )Nz
            def do_testcmdwithnodocs(self, arg):
                pass

            import pdb
            pdb.Pdb.do_testcmdwithnodocs = do_testcmdwithnodocs
        zA
            continue
            help testcmdwithnodocs
         AttributeErrorzCCalling help on a command with no docs should be handled gracefullyz;*** No help for 'testcmdwithnodocs'; __doc__ string missingz<Calling help on a command with no docs should print an error)r   r0  r  )r   r   r   r   r   outputs         r   test_issue46434PdbTestCase.test_issue46434D  sc     ,,V>,B6<R0)6^	`SU[T	Vr   c                 l   SnSnSn[        SS5       nUR                  [        R                  " U5      5        S S S 5        U R	                  [
        R                  S5        U R                  X5      u  pVU R                  [        S UR                  5        5       5      S5        g ! , (       d  f       Nr= f)Nz
            from bar import bar

            def foo():
                bar()

            def nope():
                pass

            def foobar():
                foo()
                nope()

            foobar()
        z
            from bar import bar
            break bar
            continue
            step
            step
            quit
        z5
            def bar():
                pass
        bar.pyr   c              3   ,   #    U  H
  nS U;   v   M     g7f)zmain.py(5)foo()->NoneNr,   .0ls     r   	<genexpr>.PdbTestCase.test_issue13183.<locals>.<genexpr>z  s     J6I'1,6I   z+Fail to step into the caller after a return)r   r   r   r   r   r   r   r   
assertTrueany
splitlines)r   r   r   r%  r   r   r   s          r   test_issue13183PdbTestCase.test_issue13183Y  s     (C AGGHOOC() !	(((3,,V>Jf6G6G6IJJ9	;	 ! s   &B%%
B3c           	      X   [        [        R                  S5       nUR                  [        R
                  " S5      R                  S5      5        S S S 5        [        R                  S[        R                  /n[        R                  " U[        R                  [        R                  [        R                  0 [        R                  ESS0ES9nU R                  UR                  R                   5        UR#                  S5      u  pEU R%                  S	US
5        g ! , (       d  f       N= f)Nr   a  
                import threading
                import pdb

                def start_pdb():
                    pdb.Pdb(readrc=False).set_trace()
                    x = 1
                    y = 1

                t = threading.Thread(target=start_pdb)
                t.start()ascii-ur   r   r   s   cont
   Error*Got an error running test script under PDBr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/  r   r0  r1  s         r   test_issue13120PdbTestCase.test_issue13120}  s     )""D)QGGHOO 
% 
 %fWo
/ * ~~tY%5%56??//??;2::;17;	 	))*)))46E	G+ *)   5D
D)c           	      X   [        [        R                  S5       nUR                  [        R
                  " S5      R                  S5      5        S S S 5        [        R                  S[        R                  /n[        R                  " U[        R                  [        R                  [        R                  0 [        R                  ESS0ES9nU R                  UR                  R                   5        UR#                  S5      u  pEU R%                  S	US
5        g ! , (       d  f       N= f)Nr   a  
                import threading
                import pdb

                evt = threading.Event()

                def start_pdb():
                    evt.wait()
                    pdb.Pdb(readrc=False).set_trace()

                t = threading.Thread(target=start_pdb)
                t.start()
                pdb.Pdb(readrc=False).set_trace()
                evt.set()
                t.join()rI  rJ  r   r   r   s
   cont
cont
rK  rL  rM  r1  s         r   test_issue36250PdbTestCase.test_issue36250  s    )""D)QGGHOO %  $VG_. *  ~~tY%5%56??//??=RZZ=!3W=	 	))*))/:6E	G3 *)rP  c                 x    SnSnSnU R                  X5      u  pEU R                  X5SR                  X55      5        g )Nzdef f: pass
r5  zSyntaxError:zE

Expected:
{}
Got:
{}
Fail to handle a syntax error in the debuggee.)r   r  format)r   r   r   r  r   r   s         r   test_issue16180PdbTestCase.test_issue16180  sG     !!,,
 	h=VH%	'r   c                     SnSnU R                  X5      u  p4U R                  UR                  S5      S5        U R                  UR                  S5      S5        g )Nz!import ast; ast.literal_eval('')
zA
            continue
            where
            quit
        zast.literal_eval('')r  r   )r   r   countr   r   r   r   r   s        r   test_issue84583PdbTestCase.test_issue84583  sZ     6
 ,,V>
 	&<=qA&<=qAr   c                     SnSnU R                  X5      u  p4SR                  UR                  5        Vs/ s H  oUR                  5       PM     sn5      nU R	                  US5        U R	                  US5        g s  snf )Nzprint('hello')z[
            continue
            run a b c
            run d e f
            quit
        
z#Restarting .* with arguments:
a b cz#Restarting .* with arguments:
d e f)r   joinrE  stripassertRegex)r   r   r   r   r   xress          r   test_issue26053PdbTestCase.test_issue26053  sv    ! ,,V>iiF,=,=,?@,?q,?@ADEDE As   A:c                 t   SnSnSn[        SS5       nUR                  [        R                  " U5      5        S S S 5        U R	                  [
        R                  S5        U R                  X5      u  pVUR                  5       nU R                  SU5        U R                  SU5        g ! , (       d  f       Nv= f)Nz~
            import bar
            def foo():
                ret = bar.bar()
                pass
            foo()
        zv
            b bar.bar
            c
            b main.py:5
            c
            p ret
            quit
        z:
            def bar():
                return 42
        r;  r   -> passz(Pdb) 42)
r   r   r   r   r   r   r   r   rE  r  )r   r   r   r%  r   r   r   liness           r   test_issue58956PdbTestCase.test_issue58956  s     (C AGGHOOC() !	(((3,,V>!!#i'j%( ! s   &B))
B7c                 z    SnSnU R                  X5      u  p4U R                  SU5        U R                  SU5        g )Nzx = 1zM
            step
            step
            step
            quit
        zThe program finishedzbdb.pyr   r  r0  r   s        r   test_step_into_botframe#PdbTestCase.test_step_into_botframe  sC      ''9	,f56*r   c                     [         R                  " S5      n[         R                  " S5      nU R                  USUSS9u  p4U R                  SU5        U R	                  SU5        g )Nz-
            a = 1
            b = 2
        zU
            # Comments should be fine
            n
            p f"{a+8=}"
        q
Tr   r   SyntaxErrorza+8=9)r   r   r   r0  r  r   r   r   r   r   s        r   test_pdbrc_basicPdbTestCase.test_pdbrc_basic  sf     " 
  !  ,,VU%UY,Z/gv&r   c                     [         R                  " S5      n[         R                  " S5      nU R                  USUSS9u  p4U R                  SU5        U R	                  SU5        g )Nz?
            a = 1
            b = 2
            c = 3
        z
            n

        rp  Trq  zb = 2zc = 3)r   r   r   r  r0  rs  s        r   test_pdbrc_empty_line!PdbTestCase.test_pdbrc_empty_line   sh      "   ! 
 ,,VU%UY,Zgv&&)r   c                     [         R                  " S5      n[         R                  " S5      nU R                  USUSS9u  p4U R                  SU5        g )N
            class A:
                def __init__(self):
                    self.attr = 1
            a = A()
            b = 2
        z
            alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
            until 6
            pi a
        rp  Trq  z
a.attr = 1r   r   r   r  rs  s        r   test_pdbrc_aliasPdbTestCase.test_pdbrc_alias2  sV     "   !  ,,VU%UY,ZlF+r   c                     [         R                  " S5      n[         R                  " S5      nU R                  USUSS9u  p4U R                  SU5        g )Nrz  z
            b 5;;c;;n
        rp  Trq  z-> b = 2r{  rs  s        r   test_pdbrc_semicolon PdbTestCase.test_pdbrc_semicolonD  sV     "   !  ,,VU%UY,Zj&)r   c                     [         R                  " S5      n[         R                  " S5      nU R                  USUSS9u  p4U R                  SU5        g )Nrz  zK
            b 6
            commands 1 ;; p a;; end
            c
        rp  Trq  z<__main__.A object atr{  rs  s        r   test_pdbrc_commandsPdbTestCase.test_pdbrc_commandsT  sW     "   !  ,,VU%UY,Z-v6r   c                 |    [         R                  " S5      nU R                  USSSS9u  p#U R                  SU5        g )Nz$
            print('hello')
        rp  invalidTrq  z(NameError: name 'invalid' is not definedr{  )r   r   r   r   s       r   test_readrc_kwargPdbTestCase.test_readrc_kwargf  sB     "  ,,VU)Y],^@&Ir   c                    [         R                  R                  SS 5      n[        R                  " 5        n[        S5         [         R                  R                  US5      nU[         R                  R                  l	         [        US5       nUR                  S5        S S S 5        U R                  [        R                  " 5       R                  S   S5        Ub  U[         R                  S'   S S S 5        S S S 5        g ! , (       d  f       Ng= f! Ub  U[         R                  S'   f f = f! , (       d  f       ND= f! , (       d  f       g = f)Nr   zos.path.expanduserr   r   r  r   )r   r   r   r   temp_dirr   pathr_  
expanduserreturn_valuer   r   r   rv   rw   rcLines)r   	save_homer  rc_pathr   s        r   test_readrc_homedirPdbTestCase.test_readrc_homedirn  s    JJNN640	!Xu5I/Jggll8X6G.5BGG+3'3'1GGI& (  !2!21!5yA()2BJJv& 0K!! (' ()2BJJv& ) 0K/J!!sT   E A D/DD!:DD/1E 
DDD,,D//
D=	9E  
Ec                 p   [        5       nSn[        5        nUR                  [        SU5      5        UR                  [        R                  " [
        R                  S5      5        [
        R                  " US9  S S S 5        U R                  UR                  5       US-   5        g ! , (       d  f       N2= f)Nz"Nobody expects... blah, blah, blahz
sys.stdout	set_trace)headerr^  )
r   r   enter_contextr   objectrv   rw   r  r   getvalue)r   r   r  	resourcess       r   test_headerPdbTestCase.test_header{  s}    5[I##E,$?@##ELL+$FGMM(  	*FTM:	 [s   A$B''
B5c                     SnSnU R                  X5      u  p4U R                  [        S UR                  5        5       5      U5        g )Nzprint("SUCCESS")/
            continue
            quit
        c              3   ,   #    U  H
  nS U;   v   M     g7fSUCCESSNr,   r=  s     r   r@  .PdbTestCase.test_run_module.<locals>.<genexpr>       H4GqIN4GrB  r   rC  rD  rE  rZ  s        r   test_run_modulePdbTestCase.test_run_module  sD    ' ,,V>HF4E4E4GHH&Qr   c                     SnSnU R                  X5      u  p4U R                  [        S UR                  5        5       5      U5        g )NzQ
            if __name__ == '__main__':
                print("SUCCESS")
        r  c              3   ,   #    U  H
  nS U;   v   M     g7fr  r,   r=  s     r   r@  9PdbTestCase.test_module_is_run_as_main.<locals>.<genexpr>  r  rB  r  rZ  s        r   test_module_is_run_as_main&PdbTestCase.test_module_is_run_as_main  sF     ,,V>HF4E4E4GHH&Qr   c                     SnU R                  SS/USS9  U R                  / SQU5      u  p#U R                  SU5        U R                  / SQU5      u  p#U R                  SU5        g )	Nz
            continue
        calendarr   r  r   )r   r  1December)r   r  z--typetext)r   r  r   r   r   r!  s       r   test_run_module_with_args%PdbTestCase.test_run_module_with_args  sd     	z4((JMM"98D	j&)MM"FQ	j&)r   c                 X    SnSnU R                  XSS/S9u  p4U R                  SU5        g )Nz@
            import sys
            print(sys.argv[1:])
        r  z--barr  )r   z['--bar', 'foo']r  rZ  s        r   test_run_script_with_args%PdbTestCase.test_run_script_with_args  s>    
 ,,VGUZK[,\(&1r   c                     SnSnU R                  X5      u  p4U R                  [        S UR                  5        5       5      U5        U R                  [	        S UR                  5        5       5      U5        g )Nz{
            if __name__ == '__main__':
                pass
                print("SUCCESS")
                pass
        z*
            b 3
            quit
        c              3   ,   #    U  H
  nS U;   v   M     g7f)zBreakpoint 1 atNr,   r=  s     r   r@  .PdbTestCase.test_breakpoint.<locals>.<genexpr>       P<Oq-2<OrB  c              3   ,   #    U  H
  nS U;  v   M     g7fr  r,   r=  s     r   r@  r    s     L8K1IQ.8KrB  )r   rC  rD  rE  allrZ  s        r   test_breakpointPdbTestCase.test_breakpoint  si     ,,V>PF<M<M<OPPRXYL8I8I8KLLfUr   c                     SnU R                  SS/U5      u  p#U R                  [        R                  UR	                  SS5      5        g )Nz(
            c
            quit
        r   rv   r5  )r   r  rv   _usagereplace)r   r   r   r   s       r   test_run_pdb_with_pdb!PdbTestCase.test_run_pdb_with_pdb  sB     e}h?JJNN4$	
r   c                 F   Sn[         R                  " U5        US-   n[        R                  " U5        [	        US5          S S S 5        U R                  [         R                  U5        U R                  SU/SSS9u  p4U R                  SU5        g ! , (       d  f       NV= f)	Nr   r   r   r   r5  r   r  z-ImportError: No module named t_main.__main__;)r   r   r   r   r   r   r   r  )r   r   r   r   r   s        r   test_module_without_a_main&PdbTestCase.test_module_without_a_main  s    %.0	
)S! "	((+6; ' 
 	EvN "!s    B
B c                 v   SnSn[         R                  " U5        US-   U-   n[        R                  " U5        [	        US-   S5          S S S 5        U R                  [         R                  U5        U R                  SUR                  SS5      /SS	S
9u  pEU R                  SU5        g ! , (       d  f       Nf= f)Nt_pkgr   /r   r   r   .r5  r   r  z;'t_pkg.t_main' is a package and cannot be directly executed)	r   r   r   makedirsr   r   r   r  r  )r   pkg_namer   modpathr   r   s         r   test_package_without_a_main'PdbTestCase.test_package_without_a_main  s    "S.;.
G'N*C0 1	(((37??3,-rq ' 
 	I	 10s   B**
B8c                     U R                  S[        R                  /SSS9u  pU R                  S[        R                   3U5        g )Nr   r5  r   r  zImportError: No module named )r   r   r   r  r   r   r   s      r   test_nonexistent_module#PdbTestCase.test_nonexistent_module  sA    i.>.>'?YZ[5i6F6F5GH&Qr   c                     [         R                  " 5        nU R                  U/SSS9u  p#U R                  SU S3U5        S S S 5        g ! , (       d  f       g = f)Nr5  r   r  zError: z is a directory)r   r  r   r  )r   r  r   r   s       r   test_dir_as_scriptPdbTestCase.test_dir_as_script  sK    !X!]]H:rq]QNFMMGH:_=vF "!!s   +A


Ac                     U R                  S/SSS9u  pU R                  SUR                  S5      S   5        U R                  / SQSSS9u  pU R                  S	UR                  S5      S   5        g )
Nz-cr5  r  r  z8pdb: error: argument -c/--command: expected one argumentr^  r   )z--spamr   rv   z*pdb: error: unrecognized arguments: --spam)r   r  splitr  s      r   test_invalid_cmd_line_options)PdbTestCase.test_invalid_cmd_line_options  ss    vrqIPSYS_S_`dSefgShi'>XYZBV\\RVEWXYEZ[r   c                     SnSnU R                  X5      u  p4U R                  [        S UR                  5        5       5      U5        g )NzY
                #This is a comment, on line 2

                print("SUCCESS")
        z
            quit
        c              3   ,   #    U  H
  nS U;   v   M     g7f)z__main__.py(4)<module>()Nr,   r=  s     r   r@  =PdbTestCase.test_blocks_at_first_code_line.<locals>.<genexpr>  s      ?*=Q 7 !*=rB  r  rZ  s        r   test_blocks_at_first_code_line*PdbTestCase.test_blocks_at_first_code_line  sQ    
 ,,V> ?*0*;*;*=? ?@F	Hr   c                 z    SnSnU R                  X5      u  p4U R                  SU5        U R                  SU5        g )Nz$
            print("hello")
        z
            filename = $_frame.f_code.co_filename
            f = open(filename, "w")
            f.write("print('goodbye')")
            import time; time.sleep(1)
            f.close()
            ll
        WARNING:
was editedr  rZ  s        r   "test_file_modified_after_execution.PdbTestCase.test_file_modified_after_execution  s@    
 ,,V>j&)lF+r   c           	      4   SnSnSn[        US5       nUR                  [        R                  " U5      5        S S S 5        U R	                  [
        R                  U5        U R	                  [
        R                  S5        [        R                  U/n[        R                  " U[        R                  [        R                  [        R                  0 [        R                  ESS0ES9 nUR                  [         R#                  U5      5      u  pxS S S 5        W=(       a    [$        R'                  U5      nU R)                  WR*                  S	5        U R-                  S
U5        U R-                  SU5        g ! , (       d  f       GNE= f! , (       d  f       N= f)Nz
            import pdb; pdb.Pdb().set_trace()
            with open(__file__, "w") as f:
                f.write("print('goodbye')\n" * 5)
                import time; time.sleep(1)
            import pdb; pdb.Pdb().set_trace()
        z3
            continue
            continue
        r   r   r   r   r   r   r   r  r  )r   r   r   r   r   r   r   r   r   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   :test_file_modified_after_execution_with_multiple_instancesFPdbTestCase.test_file_modified_after_execution_with_multiple_instances  s+   
 (C AGGHOOF+, !	(((3	((-8~~x(! oo!AA%7A
 ((H)=>IF
 0ELL0!,j&)lF+# ! 

 
s   &E7)'F	7
F	
Fc                     SnSnU R                  X5      u  p4U R                  SU5        U R                  SU5        U R                  SU5        g )Nz
            import random
            # Any code with a source to step into so this script is not checked
            # for changes when it's being changed
            random.randint(1, 4)
            print("hello")
        aL  
            ll
            n
            s
            filename = $_frame.f_back.f_code.co_filename
            def change_file(content, filename):
                with open(filename, "w") as f:
                    f.write(f"print({content})")

            change_file('world', filename)
            restart
            ll
        helloworldr  rl  rZ  s        r   /test_file_modified_after_execution_with_restart;PdbTestCase.test_file_modified_after_execution_with_restart<  sR     ,,V>gv&gv& 	V,r   c                 V    SnSnU R                  X5      u  p4U R                  SU5        g )NzZ
            def foo():
                raise ValueError("foo")
            foo()
        zX
            continue
            restart
            continue
            quit
        
Restartingr  rZ  s        r   test_post_mortem_restart$PdbTestCase.test_post_mortem_restart[  s2     ,,V>lF+r   c                 f   SU l         [        R                  " U R                   5        U R                   S-   nU R                   S-   nU R                   S-   nU R                  [        R                  U R                   5        [        R
                  " U R                   5        [        US5       nUR                  [        R                  " S5      5        S S S 5        [        US5       nUR                  [        R                  " S5      5        S S S 5        [        US5       nUR                  [        R                  " S5      5        S S S 5        S	nU R                  S
U R                   /U5      u  pgU R                  [        S UR                  5        5       5      U5        U R                  [        S UR                  5        5       5      5        U R                  [        S UR                  5        5       5      5        g ! , (       d  f       GN4= f! , (       d  f       GN= f! , (       d  f       N= f)Nr   r   r   
/module.pyr   6
                top_var = "VAR from top"
            z
                from . import top_var
                from .module import var
                from . import module
                pass # We'll stop here and print the vars
            zY
                var = "VAR from module"
                var2 = "second var"
            zz
            b 5
            c
            p top_var
            p var
            p module.var2
            quit
        r   c              3   ,   #    U  H
  nS U;   v   M     g7fzVAR from moduleNr,   r=  s     r   r@  4PdbTestCase.test_relative_imports.<locals>.<genexpr>  r  rB  c              3   ,   #    U  H
  nS U;   v   M     g7f)zVAR from topNr,   r=  s     r   r@  r    s     M9LANa/9LrB  c              3   ,   #    U  H
  nS U;   v   M     g7f)z
second varNr,   r=  s     r   r@  r    s     K7J!LA-7JrB  r   r   r   r   r   r   r   r   r   r   r   rC  rD  rE  r   r   r   module_filer   r   r   r!  s           r   test_relative_imports!PdbTestCase.test_relative_importsl  s   #))*$$~5	$$~5	&&5	(($*:*:;
!!")S!QGGHOO %   " )S!QGGHOO %   " +s#qGGHOO %   $
 MM4)9)9":HE	PF<M<M<OPPRXYM9J9J9LMMNKv7H7H7JKKL7 "! "! $#s$   +&G>%&H&H">
H
H"
H0c                    SU l         [        R                  " U R                   5        U R                   S-   nU R                   S-   nU R                   S-   nU R                  [        R                  U R                   5        [        R
                  " U R                   5        [        US5       nUR                  [        R                  " S5      5        S S S 5        [        US5       nUR                  [        R                  " S5      5        S S S 5        [        US5       nUR                  [        R                  " S5      5        S S S 5        S	nU R                  S
U R                   S-   /U5      u  pgU R                  [        S UR                  5        5       5      U5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f)Nr   z	/runme.pyr   r  r   r  zl
                from . import module
                pass # We'll stop here and print the vars
            z5
                var = "VAR from module"
            zQ
            b 3
            c
            p module.var
            quit
        r   z.runmec              3   ,   #    U  H
  nS U;   v   M     g7fr  r,   r=  s     r   r@  DPdbTestCase.test_relative_imports_on_plain_module.<locals>.<genexpr>  r  rB  r  r  s           r   %test_relative_imports_on_plain_module1PdbTestCase.test_relative_imports_on_plain_module  sn   #))*$${2	$$~5	&&5	(($*:*:;
!!")S!QGGHOO %   " )S!QGGHOO %   "
 +s#qGGHOO %   $ MM4)9)9H)D"ExP	PF<M<M<OPPRXY) "! "!
 $#s$   +&F#%&F4&G#
F14
G
Gc                     SR                  / SQ5      nU R                  SUS-   5      u  p#U R                  UR                  5       SS  / SQ5        g )Nr^  )zprint(]zdebug print(zdebug doesnotexistcpassr   )
rg  zU(Pdb) *** SyntaxError: closing parenthesis ']' does not match opening parenthesis '('!(Pdb) ENTERING RECURSIVE DEBUGGERz%*** SyntaxError: '(' was never closedLEAVING RECURSIVE DEBUGGERr  z> <string>(1)<module>()z9((Pdb)) *** NameError: name 'doesnotexist' is not definedr  (Pdb) r_  r   r   rE  r  s       r   test_errors_in_command"PdbTestCase.test_errors_in_command  sT    99 
  ''4@	**,QR0 3
 	r   c                 6   ^  U 4S jnU" SS5        U" SS5        g )Nc                    > SR                  SU  3S/5      nTR                  SUS-   5      u  p4TR                  UR                  5       SS  SSU  SU 3S	/5        g )
Nr^  zrun qr  r   rg  z(Pdb) *** Cannot run z: r  r	  )bad_argmsgr   r   r!  r   s        r   check*PdbTestCase.test_issue34266.<locals>.check  sx    yywi " H ++FHtODIFV..04'y3%87 r   \zNo escaped character"zNo closing quotationr,   )r   r  s   ` r   test_issue34266PdbTestCase.test_issue34266  s     
	 	d*+c)*r   c                 b   [         R                  " S5      nSn[        R                  " 5        nS[        R
                  R                  U5       3nU R                  X5      u  pVU R                  UR                  S5      S   R                  S5      U5        S S S 5        g ! , (       d  f       g = f)NQ
            import sys
            print('sys.path[0] is', sys.path[0])
        c
q(Pdb) sys.path[0] is r^  r  r  )r   r   r   temp_cwdr   r  realpathr   r   r  rstrip)r   r   r   cwdr  r   r   s          r   test_issue42384PdbTestCase.test_issue42384  s     "  !S.rww/?/?/D.EFH!00BNFV\\$/299$?J "!!s   A)B  
B.c                    [         R                  " S5      nSn[        R                  " 5        n[        R
                  R                  U5      n[        R
                  R                  US5      n[        R
                  R                  US5      nSU 3n[        R                  " U5        [        [        R
                  R                  US5      S5       nUR                  U5        S S S 5        [        R                  " U5        [        R                  " [        R
                  R                  US5      [        R
                  R                  US5      5        U R                  [        R
                  R                  SS5      /U5      u  pU R                  UR                  S5      S	   R                  S
5      U5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr  r  dir_onedir_twor  foo.pyr   r^  r  r  )r   r   r   r  r   r  r  r_  r   r   r   symlinkr   r   r  r  )
r   r   r   r  r"  r#  r  r   r   r   s
             r   test_issue42384_symlink#PdbTestCase.test_issue42384_symlink  sK     "  !S''""3'Cggll3	2Gggll3	2G.wi8HHHWbggll7H5s;q <HHWJJrww||GX6Wh8WX!]]BGGLLH,M+NPXYNFV\\$/299$?J "! <; "!s%   B%GG%CG
G	G
G$c                     [         R                  " S5      nSn[        R                  " 5        nU R	                  XSS0S9u  pES[
        R                  R                  U5       3nU R                  Xd5        S S S 5        g ! , (       d  f       g = f)Nzk
            import sys
            import random
            print('sys.path[0] is', sys.path[0])
        zc
PYTHONSAFEPATHr  )r   zsys.path[0] is )	r   r   r   r  r   r   r  r  r0  )r   r   r   r  r   r!  
unexpecteds          r   test_safe_pathPdbTestCase.test_safe_path  s      " 
  !S++FIY[^H_+`IF*277+;+;C+@*ABJZ0	 "!!s   AA??
Bc                    [         R                  " 5        n[        SS5       n[        R                  " S5      nUR                  U5        S S S 5        [        R                  R                  US5      n[        R                  " U5        [        R                  " [        R                  R                  US5      5        [        R                  R                  US5      n[        US5       nUR                  S5        S S S 5        U R                  S/S5      u  pgSnU R                  UR                  S5      S	   R                  S
5      U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       Ns= f! , (       d  f       g = f)Nr$  r   z
                    print('The correct file was executed')

                    import os
                    os.chdir("subdir")
                subdirz$print("The wrong file was executed")zc
c
qz#(Pdb) The correct file was executedr^  r  r  )r   r  r   r   r   r   r   r  r_  r   r   r   r  r  )	r   r  r   sr.  
wrong_filer   r   r  s	            r   test_issue42383PdbTestCase.test_issue42383  s   !Sh$OO %  
 % WW\\#x0FHHVHHRWW\\&(34fh7Jj#&!>? ' "]]H:yANF<HV\\$/299$?J) "!$$ '& "!s<   E9(EBE9)E(;AE9
E%	 E9(
E6	2E99
Fc                 |    Sn[         R                  " S5      nU R                  X5      u  p4U R                  U5        g )Nz            def func():
                def inner(v): pass
                inner(
                    42
                )
            func()
        zj
            break func
            continue
            next
            next
            jump 2
        )r   r   r   assertFalserZ  s        r   test_gh_94215_crashPdbTestCase.test_gh_94215_crash)  s@     ?? $  ,,V> r   c                    SnSnSn[        SS5       nUR                  [        R                  " U5      5        S S S 5        [        SS5       nUR                  [        R                  " U5      5        S S S 5        U R	                  [
        R                  S5        U R	                  [
        R                  S5        U R                  S/U5      u  pVU R                  SUS5        g ! , (       d  f       N= f! , (       d  f       N= f)	Nza
        def func():
            x = "Sentinel string for gh-93696"
            print(x)
        aL  
        import os
        import sys

        def _create_fake_frozen_module():
            with open('gh93696.py') as f:
                src = f.read()

            # this function has a co_filename as if it were in a frozen module
            dummy_mod = compile(src, "<frozen gh93696>", "exec")
            func_code = dummy_mod.co_consts[0]

            mod = type(sys)("gh93696")
            mod.func = type(lambda: None)(func_code, mod.__dict__)
            mod.__file__ = 'gh93696.py'

            return mod

        mod = _create_fake_frozen_module()
        mod.func()
        zf
            break 20
            continue
            step
            list
            quit
        z
gh93696.pyr   zgh93696_host.pyz"x = "Sentinel string for gh-93696"zSentinel statement not found)	r   r   r   r   r   r   r   r   r  )r   
frozen_srchost_programr   r   r   r   s          r   test_gh_93696_frozen_list%PdbTestCase.test_gh_93696_frozen_list<  s    

* ,$GGHOOJ/0 % #S)QGGHOOL12 * 		((,7	((*;<(9':HE:FDbc %$ *)s   &C$&C5$
C25
Dc                     SnSnU R                  X5      u  p4U R                  SU5        U R                  X5      u  p4U R                  SU5        g )Nr5  rp  z
main.py(0)z__main__.py(0))r   r  r   r   s        r   test_empty_filePdbTestCase.test_empty_filej  sO     ''9	lF+''9	&/r   c                 P   [         R                  R                  [         R                  R                  [        5      S5      n[         R
                  " U5       HK  nUR                  S5      (       d  M  U R                  [         R                  R                  X5      /S5        MM     g )Nencoded_modulesz.pyr  )r   r  r_  dirname__file__listdirendswithr   )r   
script_dirr   s      r   test_non_utf8_encoding"PdbTestCase.test_non_utf8_encodingt  sf    WW\\"''//(";=NO


:.H  ''rww||JABCH /r   c                    [         R                  " 5        n[        R                  " [        R                  R                  US5      5        [        R                  " S5      n[        [        R                  R                  USS5      S5       nUR                  U5        S S S 5        [        R                  " [        R                  R                  US5      [        R                  R                  US5      5        U R                  [        R                  R                  US5      /SR                  / SQ5      5      u  pEU R                  SU5        U R                  S	U5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)
Nsourcezg
                def f(x):
                    return x + 1
                f(21 + 21)
                z__main__.pyr   z
zipapp.pyzr^  )zb fr  zp xr  42zreturn x + 1)r   r  r   r   r  r_  r   r   r   r   zipappcreate_archiver   r  )r   r  r   r   r   r!  s         r   test_zipappPdbTestCase.test_zipappz  s   !XHHRWW\\(H56__F bggll8X}EsKq L!!"'',,x"B"$'',,x"FHrww||Hl'K&Ldii Y O IF MM$'MM.&1) "! LK "!s%   A6E;E*CE;*
E8	4E;;
F	)r   )r   N)r   NNNF)Gr'   r(   r)   r*   r   unittestskipIfr   flags	safe_pathr   r   r   r  r	  r  r  r  r"  r,  r2  r8  rF  rN  rR  r   rV  r[  rd  ri  rm  rt  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r   skip_unless_symlinkr&  r+  r1  r5  r:  r=  rF  rM  r+   r,   r   r   r   r     s   + __SYY((>@ &'@6 ,-!%#'!#(:AF5
 
"

&=2MV*";HG8G< ' ' B B F)<+' *$,$* 7$J3;R
R
*2V	
O R
G
\H,&!,F->,"#MJZ>2+ K ""K #K01"K.!&,d\0I2r   r   c                   2    \ rS rSrS rS rS rS rS rSr	g)	ChecklineTestsi  c                 .    [         R                  " 5         g r   )	linecache
clearcacher   s    r   setUpChecklineTests.setUp  s    r   c                 L    [         R                  " [         R                  5        g r   r   r   s    r   r   ChecklineTests.tearDown  r   r   c                    [        [        R                  S5       nUR                  S5        S S S 5        [        R
                  " 5       nU R                  UR                  [        R                  S5      S5        g ! , (       d  f       NT= fNr   z
print(123)r   )r   r   r   r   rv   rw   r   	checkliner   r   dbs      r   test_checkline_before_debugging.ChecklineTests.test_checkline_before_debugging  sZ    )""C(AGGL! )WWYi&6&6:A> )(s   A;;
B	c                 8   [        [        R                  S5       nUR                  S5        S S S 5        [        R
                  " 5       nUR                  5         U R                  UR                  [        R                  S5      S5        g ! , (       d  f       Nd= fr^  )	r   r   r   r   rv   rw   resetr   r_  r`  s      r   test_checkline_after_reset)ChecklineTests.test_checkline_after_reset  sc    )""C(AGGL! )WWY

i&6&6:A>	 )(s   B
Bc                    [         R                  " S5      n[        [        R                  S5       nUR                  U5        S S S 5        [        UR                  5       5      S-   n[        [        5       5         [        R                  " 5       n[        U5       H2  nU R                  UR                  [        R                  U5      5        M4     S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nz\
            # Comment
            """ docstring """
            ''' docstring '''

        r   r  )r   r   r   r   r   r   lenrE  r   r   rv   rw   ranger4  r_  )r   r/  r   	num_linesra  linenos         r    test_checkline_is_not_executable/ChecklineTests.test_checkline_is_not_executable  s    OO   )""C(AGGAJ )'!+	XZ(B	*  i.>.>!GH + )( )( )(s   C:AC+
C(+
C9r,   N)
r'   r(   r)   r*   rY  r   rb  rf  rm  r+   r,   r   r   rU  rU    s    +??Ir   rU  c                   B    \ rS rSr\S 5       rS rS rS rS r	S r
Srg	)
PdbTestReadlinei  c                 f    [        S5      nUR                  S:X  a  [        R                  " S5      eg )Nreadlineeditlinez)libedit readline is not supported for pdb)r	   backendrO  SkipTest)clsrr  s     r   
setUpClassPdbTestReadline.setUpClass  s3     !,z)##$OPP *r   c                     [         R                  " S5      nSn[        X5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        g )Nz
            import pdb; pdb.Pdb().set_trace()
            # Concatenate strings so that the output doesn't appear in the source
            print('hello' + '!')
        s
   co		ntin	
s   commandss	   conditions   continues   hello!r   r   r
   r  r   r   r   r7  s       r   test_basic_completion%PdbTestReadline.test_basic_completion  s^     "  "'k6*lF+k6*i(r   c                     [         R                  " S5      nSnUS-  nUS-  nUS-  n[        X5      nU R                  SU5        U R                  SU5        U R                  SU5        g )	NS
            value = "speci"
            import pdb; pdb.Pdb().set_trace()
        s   val	 + 'al'
s   p val	 + 'es'
s   $_fra	
   c
   specials   speciess   $_framerz  r{  s       r   test_expression_completion*PdbTestReadline.test_expression_completion  sn     "  "$$'j&)j&)j&)r   c                 x    [         R                  " S5      nSnUS-  n[        X5      nU R                  SU5        g )Nr  s   pri	val	 + 'al')
r  r  rz  r{  s       r   test_builtin_completion'PdbTestReadline.test_builtin_completion  s?     "  ( 	'j&)r   c                 x    [         R                  " S5      nSnUS-  n[        X5      nU R                  SU5        g )Nz
            def f():
                original = "I live Pythin"
                import pdb; pdb.Pdb().set_trace()
            f()
        s   orig	.repl	('i', 'o')
r  s   I love Pythonrz  r{  s       r   test_local_namespace$PdbTestReadline.test_local_namespace  s@     "  - 	'&/r   c                     [         R                  " S5      nSnUS-  nUS-  nUS-  nUS-  n[        X5      nU R                  SU5        g )Nz7
            import pdb; pdb.Pdb().set_trace()
        s   def func():
s   	ret	 40 + 2
   
s   fun	()
r  s   42rz  r{  s       r   test_multiline_completion)PdbTestReadline.test_multiline_completion  s[     "  !$$'eV$r   r,   N)r'   r(   r)   r*   classmethodrw  r|  r  r  r  r  r+   r,   r   r   rp  rp    s1     Q Q)$*** 0$%r   rp  c                 \    SSK Jn  UR                  [        R                  " U5      5        U$ )Nr   )test_pdb)testr  addTestdoctestDocTestSuite)loadertestspatternr  s       r   
load_testsr    s!    	MM'&&x01Lr   __main__)lr  r   rv   r   typesr  rO  r   r   rW  rK  
contextlibr   r   ior   r  r   test.supportr   r   test.support.import_helperr	   test.support.pty_helperr
   r   unittest.mockr   has_socket_supportSKIP_ASYNCIO_TESTSr  r   r.   r1   r6   r8   r:   r<   r>   r@   rB   rD   rH   rJ   rL   rN   rP   rR   rQ  no_siterT   rV   rX   rZ   r\   r^   r`   rb   rd   rf   rh   rj   rl   
ModuleTypemodexec__dict__ro   rq   rz   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   requires_subprocessTestCaser   rU  rp  r  r'   mainr,   r   r   <module>r     s    	 
 
        1   7 4 6  "444 *6 *"8Wr&BH"H&PAF4@	aF'R=~GR8z yy2hYxNb5pGT"J"J*bJ?D1h4: '( =s|| L,^+\?
 ,>@=~ :x?B9v ,\.` 1f(T1f D=~&P2:/bDL82("".601f'R1h 	A2(## A2 A2H "IX&& "IJ 	b%h'' b% b%J zMMO r   