webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
Public Member Functions | |
def | __init__ (self, test_stream, handler) |
def | tearDown (self) |
def | messages (self) |
def | assertMessages (self, messages) |
Static Public Member Functions | |
def | setUp (test_case, logging_level=logging.INFO) |
Supports end-to-end unit-testing of log messages. Sample usage: class SampleTest(unittest.TestCase): def setUp(self): self._log = LogTesting.setUp(self) # Turn logging on. def tearDown(self): self._log.tearDown() # Turn off and reset logging. def test_logging_in_some_method(self): call_some_method() # Contains calls to _log.info(), etc. # Check the resulting log messages. self._log.assertMessages(["INFO: expected message #1", "WARNING: expected message #2"])
def webkitpy.common.system.logtesting.LogTesting.__init__ | ( | self, | |
test_stream, | |||
handler | |||
) |
Create an instance. This method should never be called directly. Instances should instead be created using the static setUp() method. Args: test_stream: A TestLogStream instance. handler: The handler added to the logger.
def webkitpy.common.system.logtesting.LogTesting.assertMessages | ( | self, | |
messages | |||
) |
Assert the current array of log messages, and clear its contents. Args: messages: A list of log message strings.
def webkitpy.common.system.logtesting.LogTesting.messages | ( | self | ) |
Return the current list of log messages.
|
static |
Configure logging for unit testing. Configures the root logger to log to a testing log stream. Only messages logged at or above the given level are logged to the stream. Messages logged to the stream are formatted in the following way, for example-- "INFO: This is a test log message." This method should normally be called in the setUp() method of a unittest.TestCase. See the docstring of this class for more details. Returns: A LogTesting instance. Args: test_case: A unittest.TestCase instance. logging_level: An integer logging level that is the minimum level of log messages you would like to test.
def webkitpy.common.system.logtesting.LogTesting.tearDown | ( | self | ) |
Assert there are no remaining log messages, and reset logging. This method asserts that there are no more messages in the array of log messages, and then restores logging to its original state. This method should normally be called in the tearDown() method of a unittest.TestCase. See the docstring of this class for more details.