diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index abe4f65b6..5e859f0e3 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -146,22 +146,25 @@ class pytestPDB(object): def do_continue(self, arg): ret = super(_PdbWrapper, self).do_continue(arg) - if self._pytest_capman: + if cls._recursive_debug == 0: tw = _pytest.config.create_terminal_writer(cls._config) tw.line() - if cls._recursive_debug == 0: + if self._pytest_capman: capturing = self._pytest_capman.is_capturing() + else: + capturing = False + if capturing: if capturing == "global": tw.sep(">", "PDB continue (IO-capturing resumed)") - elif capturing: + else: tw.sep( ">", "PDB continue (IO-capturing resumed for %s)" % capturing, ) - else: - tw.sep(">", "PDB continue") self._pytest_capman.resume() + else: + tw.sep(">", "PDB continue") cls._pluginmanager.hook.pytest_leave_pdb( config=cls._config, pdb=self ) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index e6b5fecda..6d4fd18e8 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -576,7 +576,8 @@ class TestPDB(object): child.sendline("c") child.expect("LEAVING RECURSIVE DEBUGGER") assert b"PDB continue" not in child.before - assert b"print_from_foo" in child.before + # No extra newline. + assert child.before.endswith(b"c\r\nprint_from_foo\r\n") child.sendline("c") child.expect(r"PDB continue \(IO-capturing resumed\)") rest = child.read().decode("utf8")