diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2018-11-04 12:25:30 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-04 12:25:30 -0300 |
commit | d1c9c545716e6a0f2dcf64502f1b15681043bb32 (patch) | |
tree | c032b659d039fd9fc57e875ae7d43d08ae0ac38b /src/_pytest/debugging.py | |
parent | bb2ed2f89853bcd56afd114996f98b3f174fbef1 (diff) | |
parent | 3d88d1827b42b7f7b0e774d19ac58f02e5c67d0a (diff) | |
download | pytest-d1c9c545716e6a0f2dcf64502f1b15681043bb32.tar.gz |
Merge pull request #4297 from nicoddemus/release-3.10.0
Release 3.10.0
Diffstat (limited to 'src/_pytest/debugging.py')
-rw-r--r-- | src/_pytest/debugging.py | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 0baa84afa..fe54d4939 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -88,10 +88,54 @@ class pytestPDB(object): capman.suspend_global_capture(in_=True) tw = _pytest.config.create_terminal_writer(cls._config) tw.line() - tw.sep(">", "PDB set_trace (IO-capturing turned off)") - cls._pluginmanager.hook.pytest_enter_pdb(config=cls._config) + if 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_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() + cls._pluginmanager.hook.pytest_leave_pdb( + config=cls._config, pdb=self + ) + self._continued = True + return ret + + do_c = do_cont = do_continue + + def setup(self, f, tb): + """Suspend on setup(). + + Needed after do_continue resumed, and entering another + breakpoint again. + """ + ret = super(_PdbWrapper, self).setup(f, tb) + if not ret and self._continued: + # pdb.setup() returns True if the command wants to exit + # from the interaction: do not suspend capturing then. + if self._pytest_capman: + self._pytest_capman.suspend_global_capture(in_=True) + return ret + + _pdb = _PdbWrapper() + cls._pluginmanager.hook.pytest_enter_pdb(config=cls._config, pdb=_pdb) + else: + _pdb = cls._pdb_cls() + if set_break: - cls._pdb_cls().set_trace(frame) + _pdb.set_trace(frame) class PdbInvoke(object): |