@@ -87,6 +87,8 @@ class ConfigWithPygmentsAndHighlight(ConfigWithPygments, ConfigWithHighlight):
8787
8888class PdbTest (pdbpp .Pdb ):
8989 use_rawinput = 1
90+ # For the sake of testing, let's never reuse the last pdb instance (3.14+)
91+ _last_pdb_instance = None
9092
9193 def __init__ (self , * args , ** kwds ):
9294 readrc = kwds .pop ("readrc" , False )
@@ -532,25 +534,21 @@ def fn():
532534 return a
533535
534536 if sys .version_info >= (3 , 13 ):
535-
536- def get_trace_lines_str (cleanup = True ) -> str :
537- """helper to avoid repeating set_trace() lines"""
538-
539- return f"""
537+ expected = textwrap .dedent (
538+ """
540539 [NUM] > .*fn()
541- -> set_trace({ "cleanup=False" if not cleanup else "" } )
540+ -> set_trace(.* )
542541 5 frames hidden .*
543- """ .strip ()
544-
545- expected = textwrap .dedent (
546- f"""
547- { get_trace_lines_str ()}
548542 # display a
549543 # c
550- { get_trace_lines_str (cleanup = False )}
544+ [NUM] > .*fn()
545+ -> set_trace(cleanup=False)
546+ 5 frames hidden .*
551547 a: 1 --> 2
552548 # c
553- { get_trace_lines_str (cleanup = False )}
549+ [NUM] > .*fn()
550+ -> set_trace(cleanup=False)
551+ 5 frames hidden .*
554552 a: 2 --> 3
555553 # c
556554 """ ,
@@ -5633,8 +5631,9 @@ def inner():
56335631
56345632 _ , lineno = inspect .getsourcelines (fn )
56355633
5636- expected = (
5637- f"""
5634+ if sys .version_info < (3 , 14 ):
5635+ expected = (
5636+ f"""
56385637 [NUM] > .*fn()
56395638 -> inner()
56405639 5 frames hidden .*
@@ -5643,29 +5642,50 @@ def inner():
56435642 # c
56445643 --Return--
56455644 """ .rstrip ()
5646- + (
5647- """
5645+ + (
5646+ """
56485647 [NUM] .*set_trace()
56495648 -> Pdb(.*).set_trace(frame)
56505649 5 frames hidden .*
56515650 # n
5652- --Return-
5651+ --Return--
56535652 [NUM] .*inner()
56545653 """
5655- if sys .version_info >= (3 , 13 )
5656- else """
5654+ if sys .version_info >= (3 , 13 )
5655+ else """
56575656 [NUM] > .*inner()->None
56585657 """
5659- )
5660- + """
5658+ )
5659+ + """
56615660 -> set_trace(cleanup=False)
56625661 5 frames hidden .*
56635662 # import pdb; pdbpp.local.GLOBAL_PDB.clear_all_breaks()
56645663 # c
56655664 1
56665665 """ .lstrip ()
5667- )
5668- check (fn , expected , add_313_fix = True )
5666+ )
5667+ check (fn , expected , add_313_fix = True )
5668+ else :
5669+ expected = f"""
5670+ [NUM] > .*fn()
5671+ -> set_trace()
5672+ 5 frames hidden .*
5673+ # break { lineno + 8 }
5674+ Breakpoint . at .*:{ lineno + 8 }
5675+ # c
5676+ [NUM] .*inner()
5677+ -> set_trace(cleanup=False)
5678+ 5 frames hidden .*
5679+ # n
5680+ --Return--
5681+ [NUM] .*inner()->None
5682+ -> set_trace(cleanup=False)
5683+ 5 frames hidden .*
5684+ # import pdb; pdbpp.local.GLOBAL_PDB.clear_all_breaks()
5685+ # c
5686+ 1
5687+ """
5688+ check (fn , expected )
56695689
56705690
56715691def test_pdbrc_continue (tmpdirhome ):
@@ -6327,17 +6347,26 @@ class Config(DefaultConfig):
63276347 """ )
63286348 )
63296349 testdir .monkeypatch .setenv ("PDBPP_COLORS" , "0" )
6330- child = testdir .spawn (f"{ quote (sys .executable )} { str (p1 )} " )
6350+ child = testdir .spawn (f"{ quote (sys .executable )} { str (p1 )} " , expect_timeout = 1 )
63316351 child .send ("completeme\t " )
6332- child .expect_exact ("\r \n (Pdb++) completeme_outer" )
6352+ if sys .version_info < (3 , 14 ):
6353+ child .expect_exact ("\r \n (Pdb++) completeme_outer" )
6354+ else :
6355+ child .expect_exact ("\r \n (Pdb++) completeme\x07 \r \x1b [19G_outer" )
63336356 child .send ("\n import pdbpp; _p = pdbpp.Pdb(); _p.reset()" )
63346357 child .send ("\n _p.interaction(frames[0], None)\n " )
63356358 child .expect_exact ("\r \n -> frames.append(sys._getframe())\r \n (Pdb++) " )
63366359 child .send ("completeme\t " )
6337- child .expect_exact ("completeme_inner" )
6360+ if sys .version_info < (3 , 14 ):
6361+ child .expect_exact ("completeme_inner" )
6362+ else :
6363+ child .expect_exact ("completeme\x07 \r \x1b [19G_inner" )
63386364 child .send ("\n q\n " )
63396365 child .send ("completeme\t " )
6340- child .expect_exact ("completeme_outer" )
6366+ if sys .version_info < (3 , 14 ):
6367+ child .expect_exact ("completeme_outer" )
6368+ else :
6369+ child .expect_exact ("completeme\x07 \r \x1b [19G_outer" )
63416370 child .send ("\n " )
63426371 child .sendeof ()
63436372
@@ -8049,7 +8078,8 @@ def f():
80498078 f ()
80508079
80518080 def test_commands_with_sticky (self ):
8052- expected = r"""
8081+ expected = (
8082+ r"""
80538083 [NUM] > .*fn()
80548084 -> for i in range(5):
80558085 5 frames hidden .*
@@ -8077,21 +8107,38 @@ def test_commands_with_sticky(self):
80778107 0
80788108 1
80798109 3
8110+ """ .rstrip ()
8111+ + (
8112+ """
80808113 stop 6
80818114 [NUM] > .*f(), 5 frames hidden
80828115
80838116 NUM def f():
80848117 NUM -> print(a)
8118+ """
8119+ if (sys .version_info < (3 , 14 ))
8120+ # before 3.14 location information is printed after calling f(), in 3.14 it's called after
8121+ else """
8122+ [NUM] > .*f(), 5 frames hidden
8123+
8124+ NUM def f():
8125+ NUM -> print(a)
8126+ stop 6
8127+ """
8128+ ).rstrip ()
8129+ + """
80858130 # import pdb; pdbpp.local.GLOBAL_PDB.clear_all_breaks()
80868131 # c
80878132 6
80888133 10
80898134 """
8135+ )
80908136
80918137 check (self .fn , expected , add_313_fix = True )
80928138
80938139 def test_commands_without_sticky (self ):
8094- expected = r"""
8140+ expected = (
8141+ r"""
80958142 [NUM] > .*fn()
80968143 -> for i in range(5):
80978144 5 frames hidden .*
@@ -8104,13 +8151,28 @@ def test_commands_without_sticky(self):
81048151 0
81058152 1
81068153 3
8154+ """ .rstrip ()
8155+ + (
8156+ """
81078157 stop 6
81088158 [NUM] > .*f()$
81098159 -> print(a)
8160+ """
8161+ if sys .version_info < (3 , 14 )
8162+ # before 3.14 location information is printed after calling f(), in 3.14 it's called after
8163+ else """
8164+ [NUM] > .*f()
8165+ -> print(a)
8166+ 5 frames hidden
8167+ stop 6
8168+ """
8169+ ).rstrip ()
8170+ + """
81108171 # import pdb; pdbpp.local.GLOBAL_PDB.clear_all_breaks()
81118172 # c
81128173 6
81138174 10
81148175 """
8176+ )
81158177
81168178 check (self .fn , expected , add_313_fix = True )
0 commit comments