| OLD | NEW |
| 1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # 1. Redistributions of source code must retain the above copyright | 6 # 1. Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # 2. Redistributions in binary form must reproduce the above copyright | 8 # 2. Redistributions in binary form must reproduce the above copyright |
| 9 # notice, this list of conditions and the following disclaimer in the | 9 # notice, this list of conditions and the following disclaimer in the |
| 10 # documentation and/or other materials provided with the distribution. | 10 # documentation and/or other materials provided with the distribution. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 Provides support for unit-testing messages logged using the built-in | 25 Provides support for unit-testing messages logged using the built-in |
| 26 logging module. | 26 logging module. |
| 27 | 27 |
| 28 Inherit from the LoggingTestCase class for basic testing needs. For | 28 Inherit from the LoggingTestCase class for basic testing needs. For |
| 29 more advanced needs (e.g. unit-testing methods that configure logging), | 29 more advanced needs (e.g. unit-testing methods that configure logging), |
| 30 see the TestLogStream class, and perhaps also the LogTesting class. | 30 see the TestLogStream class, and perhaps also the LogTesting class. |
| 31 | 31 |
| 32 """ | 32 """ |
| 33 | 33 |
| 34 import logging | 34 import logging |
| 35 import webkitpy.thirdparty.unittest2 as unittest | 35 import unittest |
| 36 | 36 |
| 37 | 37 |
| 38 class TestLogStream(object): | 38 class TestLogStream(object): |
| 39 | 39 |
| 40 """Represents a file-like object for unit-testing logging. | 40 """Represents a file-like object for unit-testing logging. |
| 41 | 41 |
| 42 This is meant for passing to the logging.StreamHandler constructor. | 42 This is meant for passing to the logging.StreamHandler constructor. |
| 43 Log messages captured by instances of this object can be tested | 43 Log messages captured by instances of this object can be tested |
| 44 using self.assertMessages() below. | 44 using self.assertMessages() below. |
| 45 | 45 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 # an explanation of why we clear the array of messages after | 249 # an explanation of why we clear the array of messages after |
| 250 # asserting its contents. | 250 # asserting its contents. |
| 251 def assertLog(self, messages): | 251 def assertLog(self, messages): |
| 252 """Assert the current array of log messages, and clear its contents. | 252 """Assert the current array of log messages, and clear its contents. |
| 253 | 253 |
| 254 Args: | 254 Args: |
| 255 messages: A list of log message strings. | 255 messages: A list of log message strings. |
| 256 | 256 |
| 257 """ | 257 """ |
| 258 self._log.assertMessages(messages) | 258 self._log.assertMessages(messages) |
| OLD | NEW |