@@ -75,6 +75,7 @@ class pytestPDB(object):
7575 _config = None
7676 _pdb_cls = pdb .Pdb
7777 _saved = []
78+ _recursive = 0
7879
7980 @classmethod
8081 def set_trace (cls , set_break = True ):
@@ -88,25 +89,33 @@ def set_trace(cls, set_break=True):
8889 capman .suspend_global_capture (in_ = True )
8990 tw = _pytest .config .create_terminal_writer (cls ._config )
9091 tw .line ()
91- if capman and capman .is_globally_capturing ():
92- tw .sep (">" , "PDB set_trace (IO-capturing turned off)" )
93- else :
94- tw .sep (">" , "PDB set_trace" )
92+ if cls ._recursive == 0 :
93+ if capman and capman .is_globally_capturing ():
94+ tw .sep (">" , "PDB set_trace (IO-capturing turned off)" )
95+ else :
96+ tw .sep (">" , "PDB set_trace" )
9597
9698 class _PdbWrapper (cls ._pdb_cls , object ):
9799 _pytest_capman = capman
98100 _continued = False
99101
102+ def do_debug (self , arg ):
103+ cls ._recursive += 1
104+ ret = super (_PdbWrapper , self ).do_debug (arg )
105+ cls ._recursive -= 1
106+ return ret
107+
100108 def do_continue (self , arg ):
101109 ret = super (_PdbWrapper , self ).do_continue (arg )
102110 if self ._pytest_capman :
103111 tw = _pytest .config .create_terminal_writer (cls ._config )
104112 tw .line ()
105- if self ._pytest_capman .is_globally_capturing ():
106- tw .sep (">" , "PDB continue (IO-capturing resumed)" )
107- else :
108- tw .sep (">" , "PDB continue" )
109- self ._pytest_capman .resume_global_capture ()
113+ if cls ._recursive == 0 :
114+ if self ._pytest_capman .is_globally_capturing ():
115+ tw .sep (">" , "PDB continue (IO-capturing resumed)" )
116+ else :
117+ tw .sep (">" , "PDB continue" )
118+ self ._pytest_capman .resume_global_capture ()
110119 cls ._pluginmanager .hook .pytest_leave_pdb (
111120 config = cls ._config , pdb = self
112121 )
0 commit comments