diff --git a/AUTHORS b/AUTHORS index 3a2c3b39d69..625e8535a40 100644 --- a/AUTHORS +++ b/AUTHORS @@ -73,3 +73,4 @@ Simon Gomizelj Russel Winder Ben Webb Alexei Kozlenok +Cal Leeming diff --git a/_pytest/pdb.py b/_pytest/pdb.py index 78fedd373fa..3269922c39e 100644 --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -53,7 +53,9 @@ class PdbInvoke: def pytest_exception_interact(self, node, call, report): capman = node.config.pluginmanager.getplugin("capturemanager") if capman: - capman.suspendcapture(in_=True) + out, err = capman.suspendcapture(in_=True) + sys.stdout.write(out) + sys.stdout.write(err) _enter_pdb(node, call.excinfo, report) def pytest_internalerror(self, excrepr, excinfo): diff --git a/testing/test_pdb.py b/testing/test_pdb.py index a2fd4d43da8..99acf3d794f 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -75,6 +75,22 @@ def test_1(): if child.isalive(): child.wait() + def test_pdb_interaction_capture(self, testdir): + p1 = testdir.makepyfile(""" + def test_1(): + print("getrekt") + assert False + """) + child = testdir.spawn_pytest("--pdb %s" % p1) + child.expect("getrekt") + child.expect("(Pdb)") + child.sendeof() + rest = child.read().decode("utf8") + assert "1 failed" in rest + assert "getrekt" not in rest + if child.isalive(): + child.wait() + def test_pdb_interaction_exception(self, testdir): p1 = testdir.makepyfile(""" import pytest