Skip to content

Commit ff89643

Browse files
committed
pdb: resume capturing after continue
After `pdb.set_trace()` capturing is turned off. This patch resumes it after using the `continue` (or `c` / `cont`) command.
1 parent 309152d commit ff89643

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

_pytest/debugging.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,23 @@ def set_trace(cls):
5959
tw.line()
6060
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
6161
cls._pluginmanager.hook.pytest_enter_pdb(config=cls._config)
62-
cls._pdb_cls().set_trace(frame)
62+
63+
class PytestPdb(cls._pdb_cls):
64+
def do_continue(self, arg):
65+
ret = super(PytestPdb, self).do_continue(arg)
66+
if self._pytest_capman:
67+
tw = _pytest.config.create_terminal_writer(cls._config)
68+
tw.line()
69+
tw.sep(">", "PDB continue (IO-capturing resumed)")
70+
self._pytest_capman.resumecapture()
71+
return ret
72+
do_c = do_cont = do_continue
73+
74+
_pdb = PytestPdb()
75+
_pdb._pytest_capman = capman
76+
else:
77+
_pdb = cls._pdb_cls()
78+
_pdb.set_trace(frame)
6379

6480

6581
class PdbInvoke:

0 commit comments

Comments
 (0)