Capturing log messages¶
Capture log messages during test execution, appending them to the error reports of failed tests.
This plugin implements startTestRun()
, startTest()
,
stopTest()
, setTestOutcome()
, and outcomeDetail()
to
set up a logging configuration that captures log messages during test
execution, and appends them to error reports for tests that fail or
raise exceptions.
Configuration [log-capture]¶
-
always-on
¶ - Default
False
- Type
boolean
-
clear-handlers
¶ - Default
False
- Type
boolean
-
date-format
¶ - Default
None
- Type
str
-
filter
¶ - Default
[‘-nose’]
- Type
list
-
format
¶ - Default
%(name)s: %(levelname)s: %(message)s
- Type
str
-
log-level
¶ - Default
NOTSET
- Type
str
Sample configuration¶
The default configuration is equivalent to including the following in a unittest.cfg
file.
[log-capture]
always-on = False
clear-handlers = False
filter = -nose
format = %(name)s: %(levelname)s: %(message)s
log-level = NOTSET