File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 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 @@ -152,8 +152,15 @@ def do_continue(self, arg):
152152 do_c = do_cont = do_continue
153153
154154 def set_quit (self ):
155+ """Raise Exit outcome when quit command is used in pdb.
156+
157+ This is a bit of a hack - it would be better if BdbQuit
158+ could be handled, but this would require to wrap the
159+ whole pytest run, and adjust the report etc.
160+ """
155161 super (_PdbWrapper , self ).set_quit ()
156- outcomes .exit ("Quitting debugger" )
162+ if cls ._recursive_debug == 0 :
163+ outcomes .exit ("Quitting debugger" )
157164
158165 def setup (self , f , tb ):
159166 """Suspend on setup().
Original file line number Diff line number Diff line change @@ -519,16 +519,17 @@ def test_1():
519519 assert "1 failed" in rest
520520 self .flush (child )
521521
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+ """
523526 p1 = testdir .makepyfile (
524527 mytest = """
525528 import pdb
526529 import pytest
527530
528531 count_continue = 0
529532
530- # Simulates pdbpp, which injects Pdb into do_debug, and uses
531- # self.__class__ in do_continue.
532533 class CustomPdb(pdb.Pdb, object):
533534 def do_debug(self, arg):
534535 import sys
@@ -577,6 +578,14 @@ def test_1():
577578 child .expect ("LEAVING RECURSIVE DEBUGGER" )
578579 assert b"PDB continue" not in child .before
579580 assert b"print_from_foo" in child .before
581+
582+ # set_debug should not raise outcomes.Exit, if used recrursively.
583+ child .sendline ("debug 42" )
584+ child .sendline ("q" )
585+ child .expect ("LEAVING RECURSIVE DEBUGGER" )
586+ assert b"ENTERING RECURSIVE DEBUGGER" in child .before
587+ assert b"Quitting debugger" not in child .before
588+
580589 child .sendline ("c" )
581590 child .expect (r"PDB continue \(IO-capturing resumed\)" )
582591 rest = child .read ().decode ("utf8" )
You can’t perform that action at this time.
0 commit comments