LoggingCaptureMixin
Capture the output from the 'django' logger and store it on the class's logger_output attribute.
Attributes
| Attribute | Type | Description |
|---|---|---|
| logger | logging.Logger | The 'django' logger instance used to capture log messages during test execution. |
| old_stream | IO stream | The original stream destination of the django logger handler, stored to allow restoration after tests complete. |
| logger_output | io.StringIO | A 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.