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 @@ -128,8 +128,15 @@ def do_continue(self, arg):
128128 do_c = do_cont = do_continue
129129
130130 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+ """
131137 super (_PdbWrapper , self ).set_quit ()
132- outcomes .exit ("Quitting debugger" )
138+ if cls ._recursive_debug == 0 :
139+ outcomes .exit ("Quitting debugger" )
133140
134141 def setup (self , f , tb ):
135142 """Suspend on setup().
Original file line number Diff line number Diff line change @@ -520,16 +520,17 @@ def test_1():
520520 assert "1 failed" in rest
521521 self .flush (child )
522522
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+ """
524527 p1 = testdir .makepyfile (
525528 mytest = """
526529 import pdb
527530 import pytest
528531
529532 count_continue = 0
530533
531- # Simulates pdbpp, which injects Pdb into do_debug, and uses
532- # self.__class__ in do_continue.
533534 class CustomPdb(pdb.Pdb, object):
534535 def do_debug(self, arg):
535536 import sys
@@ -578,6 +579,14 @@ def test_1():
578579 child .expect ("LEAVING RECURSIVE DEBUGGER" )
579580 assert b"PDB continue" not in child .before
580581 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+
581590 child .sendline ("c" )
582591 child .expect (r"PDB continue \(IO-capturing resumed\)" )
583592 rest = child .read ().decode ("utf8" )
You can’t perform that action at this time.
0 commit comments