print captured logs before entering pdb
This commit is contained in:
parent
f263932883
commit
069f32a8c4
|
@ -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")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Captured logs are printed before entering pdb.
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue