@@ -75,6 +75,7 @@ class pytestPDB(object):
75
75
_config = None
76
76
_pdb_cls = pdb .Pdb
77
77
_saved = []
78
+ _recursive = 0
78
79
79
80
@classmethod
80
81
def set_trace (cls , set_break = True ):
@@ -88,25 +89,33 @@ def set_trace(cls, set_break=True):
88
89
capman .suspend_global_capture (in_ = True )
89
90
tw = _pytest .config .create_terminal_writer (cls ._config )
90
91
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" )
95
97
96
98
class _PdbWrapper (cls ._pdb_cls , object ):
97
99
_pytest_capman = capman
98
100
_continued = False
99
101
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
+
100
108
def do_continue (self , arg ):
101
109
ret = super (_PdbWrapper , self ).do_continue (arg )
102
110
if self ._pytest_capman :
103
111
tw = _pytest .config .create_terminal_writer (cls ._config )
104
112
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 ()
110
119
cls ._pluginmanager .hook .pytest_leave_pdb (
111
120
config = cls ._config , pdb = self
112
121
)
0 commit comments