Merge pull request #3998 from blueyed/logging-del
logging: del item.catch_log_handler only in teardown
This commit is contained in:
commit
7aff81739e
|
@ -0,0 +1 @@
|
|||
Fix issue that prevented some caplog properties (for example ``record_tuples``) from being available when entering the debugger with ``--pdb``.
|
|
@ -445,8 +445,8 @@ class LoggingPlugin(object):
|
|||
try:
|
||||
yield # run test
|
||||
finally:
|
||||
del item.catch_log_handler
|
||||
if when == "teardown":
|
||||
del item.catch_log_handler
|
||||
del item.catch_log_handlers
|
||||
|
||||
if self.print_logs:
|
||||
|
|
|
@ -397,6 +397,24 @@ class TestPDB(object):
|
|||
child.read()
|
||||
self.flush(child)
|
||||
|
||||
def test_pdb_with_caplog_on_pdb_invocation(self, testdir):
|
||||
p1 = testdir.makepyfile(
|
||||
"""
|
||||
def test_1(capsys, caplog):
|
||||
import logging
|
||||
logging.getLogger(__name__).warning("some_warning")
|
||||
assert 0
|
||||
"""
|
||||
)
|
||||
child = testdir.spawn_pytest("--pdb %s" % str(p1))
|
||||
child.send("caplog.record_tuples\n")
|
||||
child.expect_exact(
|
||||
"[('test_pdb_with_caplog_on_pdb_invocation', 30, 'some_warning')]"
|
||||
)
|
||||
child.sendeof()
|
||||
child.read()
|
||||
self.flush(child)
|
||||
|
||||
def test_set_trace_capturing_afterwards(self, testdir):
|
||||
p1 = testdir.makepyfile(
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue