Skip to content

Commit 448830e

Browse files
committed
Do not print INTERNALERROR with --pdb
This gets printed by the terminal reporter already, and currently results in the same error being displayed twice, e.g. when raising an `Exception` manually from `pytest.debugging.pytest_exception_interact`.
1 parent d3d8d53 commit 448830e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

changelog/4132.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix duplicate printing of internal errors when using ``--pdb``.

src/_pytest/debugging.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ def pytest_exception_interact(self, node, call, report):
109109
_enter_pdb(node, call.excinfo, report)
110110

111111
def pytest_internalerror(self, excrepr, excinfo):
112-
for line in str(excrepr).split("\n"):
113-
sys.stderr.write("INTERNALERROR> %s\n" % line)
114-
sys.stderr.flush()
115112
tb = _postmortem_traceback(excinfo)
116113
post_mortem(tb)
117114

testing/test_pdb.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,12 @@ def pytest_runtest_protocol():
334334
)
335335
p1 = testdir.makepyfile("def test_func(): pass")
336336
child = testdir.spawn_pytest("--pdb %s" % p1)
337-
# child.expect(".*import pytest.*")
338337
child.expect("Pdb")
338+
339+
# INTERNALERROR is only displayed once via terminal reporter.
340+
assert len([x for x in child.before.decode().splitlines()
341+
if x.startswith("INTERNALERROR> Traceback")]) == 1
342+
339343
child.sendeof()
340344
self.flush(child)
341345

0 commit comments

Comments
 (0)