Created
October 6, 2011 04:14
-
-
Save felipe-prenholato/1266513 to your computer and use it in GitHub Desktop.
Mock Logging Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockLoggingHandler(logging.Handler): | |
"""Mock logging handler to check for expected logs.""" | |
def __init__(self, *args, **kwargs): | |
self.reset() | |
logging.Handler.__init__(self, *args, **kwargs) | |
def emit(self, record): | |
self.messages[record.levelname.lower()].append(record.getMessage()) | |
def reset(self): | |
self.messages = { | |
'debug': [], | |
'info': [], | |
'warning': [], | |
'error': [], | |
'critical': [], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment