summaryrefslogtreecommitdiff
path: root/src/_pytest/debugging.py
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2018-11-08 22:17:57 +0100
committerDaniel Hahler <git@thequod.de>2019-02-11 14:52:20 +0100
commit9feb4941f4e57b718427892eab0510069ec453d5 (patch)
treead7d306c7051649f024d2ac33643becc8c4d0a84 /src/_pytest/debugging.py
parent386e801a5afd0726d658584c145ca087f686026b (diff)
downloadpytest-9feb4941f4e57b718427892eab0510069ec453d5.tar.gz
pdb: fix capturing with recursive debugging and pdb++
While I think that pdb++ should be fixed in this regard (by using `pdb.Pdb`, and not `self.__class__` maybe), this ensures that custom debuggers like this are working.
Diffstat (limited to 'src/_pytest/debugging.py')
-rw-r--r--src/_pytest/debugging.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py
index 7a1060ae0..6b401aa0b 100644
--- a/src/_pytest/debugging.py
+++ b/src/_pytest/debugging.py
@@ -75,6 +75,7 @@ class pytestPDB(object):
_config = None
_pdb_cls = pdb.Pdb
_saved = []
+ _recursive_debug = 0
@classmethod
def _init_pdb(cls, *args, **kwargs):
@@ -87,29 +88,37 @@ class pytestPDB(object):
capman.suspend_global_capture(in_=True)
tw = _pytest.config.create_terminal_writer(cls._config)
tw.line()
- # Handle header similar to pdb.set_trace in py37+.
- header = kwargs.pop("header", None)
- if header is not None:
- tw.sep(">", header)
- elif capman and capman.is_globally_capturing():
- tw.sep(">", "PDB set_trace (IO-capturing turned off)")
- else:
- tw.sep(">", "PDB set_trace")
+ if cls._recursive_debug == 0:
+ # Handle header similar to pdb.set_trace in py37+.
+ header = kwargs.pop("header", None)
+ if header is not None:
+ tw.sep(">", header)
+ elif capman and capman.is_globally_capturing():
+ tw.sep(">", "PDB set_trace (IO-capturing turned off)")
+ else:
+ tw.sep(">", "PDB set_trace")
class _PdbWrapper(cls._pdb_cls, object):
_pytest_capman = capman
_continued = False
+ def do_debug(self, arg):
+ cls._recursive_debug += 1
+ ret = super(_PdbWrapper, self).do_debug(arg)
+ cls._recursive_debug -= 1
+ return ret
+
def do_continue(self, arg):
ret = super(_PdbWrapper, self).do_continue(arg)
if self._pytest_capman:
tw = _pytest.config.create_terminal_writer(cls._config)
tw.line()
- if self._pytest_capman.is_globally_capturing():
- tw.sep(">", "PDB continue (IO-capturing resumed)")
- else:
- tw.sep(">", "PDB continue")
- self._pytest_capman.resume_global_capture()
+ if cls._recursive_debug == 0:
+ if self._pytest_capman.is_globally_capturing():
+ tw.sep(">", "PDB continue (IO-capturing resumed)")
+ else:
+ tw.sep(">", "PDB continue")
+ self._pytest_capman.resume_global_capture()
cls._pluginmanager.hook.pytest_leave_pdb(
config=cls._config, pdb=self
)