File tree 3 files changed +23
-4
lines changed 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change
1
+ The pdb ``quit `` command is handled properly when used after the ``debug `` command with `pdb++ `_.
2
+
3
+ .. _pdb++ : https://pypi.org/project/pdbpp/
Original file line number Diff line number Diff line change @@ -128,8 +128,15 @@ def do_continue(self, arg):
128
128
do_c = do_cont = do_continue
129
129
130
130
def set_quit (self ):
131
+ """Raise Exit outcome when quit command is used in pdb.
132
+
133
+ This is a bit of a hack - it would be better if BdbQuit
134
+ could be handled, but this would require to wrap the
135
+ whole pytest run, and adjust the report etc.
136
+ """
131
137
super (_PdbWrapper , self ).set_quit ()
132
- outcomes .exit ("Quitting debugger" )
138
+ if cls ._recursive_debug == 0 :
139
+ outcomes .exit ("Quitting debugger" )
133
140
134
141
def setup (self , f , tb ):
135
142
"""Suspend on setup().
Original file line number Diff line number Diff line change @@ -520,16 +520,17 @@ def test_1():
520
520
assert "1 failed" in rest
521
521
self .flush (child )
522
522
523
- def test_pdb_interaction_continue_recursive (self , testdir ):
523
+ def test_pdb_with_injected_do_debug (self , testdir ):
524
+ """Simulates pdbpp, which injects Pdb into do_debug, and uses
525
+ self.__class__ in do_continue.
526
+ """
524
527
p1 = testdir .makepyfile (
525
528
mytest = """
526
529
import pdb
527
530
import pytest
528
531
529
532
count_continue = 0
530
533
531
- # Simulates pdbpp, which injects Pdb into do_debug, and uses
532
- # self.__class__ in do_continue.
533
534
class CustomPdb(pdb.Pdb, object):
534
535
def do_debug(self, arg):
535
536
import sys
@@ -578,6 +579,14 @@ def test_1():
578
579
child .expect ("LEAVING RECURSIVE DEBUGGER" )
579
580
assert b"PDB continue" not in child .before
580
581
assert b"print_from_foo" in child .before
582
+
583
+ # set_debug should not raise outcomes.Exit, if used recrursively.
584
+ child .sendline ("debug 42" )
585
+ child .sendline ("q" )
586
+ child .expect ("LEAVING RECURSIVE DEBUGGER" )
587
+ assert b"ENTERING RECURSIVE DEBUGGER" in child .before
588
+ assert b"Quitting debugger" not in child .before
589
+
581
590
child .sendline ("c" )
582
591
child .expect (r"PDB continue \(IO-capturing resumed\)" )
583
592
rest = child .read ().decode ("utf8" )
You can’t perform that action at this time.
0 commit comments