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 @@ -176,8 +176,15 @@ def do_continue(self, arg):
176
176
do_c = do_cont = do_continue
177
177
178
178
def set_quit (self ):
179
+ """Raise Exit outcome when quit command is used in pdb.
180
+
181
+ This is a bit of a hack - it would be better if BdbQuit
182
+ could be handled, but this would require to wrap the
183
+ whole pytest run, and adjust the report etc.
184
+ """
179
185
super (_PdbWrapper , self ).set_quit ()
180
- outcomes .exit ("Quitting debugger" )
186
+ if cls ._recursive_debug == 0 :
187
+ outcomes .exit ("Quitting debugger" )
181
188
182
189
def setup (self , f , tb ):
183
190
"""Suspend on setup().
Original file line number Diff line number Diff line change @@ -519,16 +519,17 @@ def test_1():
519
519
assert "1 failed" in rest
520
520
self .flush (child )
521
521
522
- def test_pdb_interaction_continue_recursive (self , testdir ):
522
+ def test_pdb_with_injected_do_debug (self , testdir ):
523
+ """Simulates pdbpp, which injects Pdb into do_debug, and uses
524
+ self.__class__ in do_continue.
525
+ """
523
526
p1 = testdir .makepyfile (
524
527
mytest = """
525
528
import pdb
526
529
import pytest
527
530
528
531
count_continue = 0
529
532
530
- # Simulates pdbpp, which injects Pdb into do_debug, and uses
531
- # self.__class__ in do_continue.
532
533
class CustomPdb(pdb.Pdb, object):
533
534
def do_debug(self, arg):
534
535
import sys
@@ -578,6 +579,14 @@ def test_1():
578
579
assert b"PDB continue" not in child .before
579
580
# No extra newline.
580
581
assert child .before .endswith (b"c\r \n print_from_foo\r \n " )
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