print captured logs before entering pdb

This commit is contained in:
Brian Maissy 2018-02-12 22:05:46 +02:00
parent f263932883
commit 069f32a8c4
3 changed files with 22 additions and 0 deletions

View File

@ -97,6 +97,11 @@ def _enter_pdb(node, excinfo, rep):
tw.sep(">", "captured stderr")
tw.line(captured_stderr)
captured_logs = rep.caplog
if len(captured_logs) > 0:
tw.sep(">", "captured logs")
tw.line(captured_logs)
tw.sep(">", "traceback")
rep.toterminal(tw)
tw.sep(">", "entering PDB")

1
changelog/3204.feature Normal file
View File

@ -0,0 +1 @@
Captured logs are printed before entering pdb.

View File

@ -187,6 +187,22 @@ class TestPDB(object):
assert "captured stderr" not in output
self.flush(child)
def test_pdb_print_captured_logs(self, testdir):
p1 = testdir.makepyfile("""
def test_1():
import logging
logging.warn("get rekt")
assert False
""")
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("captured logs")
child.expect("get rekt")
child.expect("(Pdb)")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
self.flush(child)
def test_pdb_interaction_exception(self, testdir):
p1 = testdir.makepyfile("""
import pytest