Skip to main content

LoggingCaptureMixin

Capture the output from the 'django' logger and store it on the class's logger_output attribute.

Attributes

AttributeTypeDescription
loggerlogging.LoggerThe 'django' logger instance used to capture log messages during test execution.
old_streamIO streamThe original stream destination of the django logger handler, stored to allow restoration after tests complete.
logger_outputio.StringIOA StringIO buffer that captures and stores all output from the 'django' logger for inspection.

Methods


setUp()

@classmethod
def setUp()

Configures the 'django' logger to redirect its output to a StringIO buffer stored in the logger_output attribute for inspection during tests.


tearDown()

@classmethod
def tearDown()

Restores the 'django' logger's original stream handler to its initial state, ensuring subsequent tests are not affected by the capture buffer.