| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 handler.setLevel(logging_level) | 143 handler.setLevel(logging_level) |
| 144 formatter = logging.Formatter("%(levelname)s: %(message)s") | 144 formatter = logging.Formatter("%(levelname)s: %(message)s") |
| 145 handler.setFormatter(formatter) | 145 handler.setFormatter(formatter) |
| 146 | 146 |
| 147 # Notice that we only change the root logger by adding a handler | 147 # Notice that we only change the root logger by adding a handler |
| 148 # to it. In particular, we do not reset its level using | 148 # to it. In particular, we do not reset its level using |
| 149 # logger.setLevel(). This ensures that we have not interfered | 149 # logger.setLevel(). This ensures that we have not interfered |
| 150 # with how the code being tested may have configured the root | 150 # with how the code being tested may have configured the root |
| 151 # logger. | 151 # logger. |
| 152 logger = LogTesting._getLogger() | 152 logger = LogTesting._getLogger() |
| 153 logger.setLevel(logging_level) |
| 153 logger.addHandler(handler) | 154 logger.addHandler(handler) |
| 154 | 155 |
| 155 return LogTesting(stream, handler) | 156 return LogTesting(stream, handler) |
| 156 | 157 |
| 157 def tearDown(self): | 158 def tearDown(self): |
| 158 """Resets logging.""" | 159 """Resets logging.""" |
| 159 logger = LogTesting._getLogger() | 160 logger = LogTesting._getLogger() |
| 160 logger.removeHandler(self._handler) | 161 logger.removeHandler(self._handler) |
| 161 | 162 |
| 162 def messages(self): | 163 def messages(self): |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 # See the code comments preceding LogTesting.assertMessages() for | 233 # See the code comments preceding LogTesting.assertMessages() for |
| 233 # an explanation of why we clear the array of messages after | 234 # an explanation of why we clear the array of messages after |
| 234 # asserting its contents. | 235 # asserting its contents. |
| 235 def assertLog(self, messages): | 236 def assertLog(self, messages): |
| 236 """Assert the current array of log messages, and clear its contents. | 237 """Assert the current array of log messages, and clear its contents. |
| 237 | 238 |
| 238 Args: | 239 Args: |
| 239 messages: A list of log message strings. | 240 messages: A list of log message strings. |
| 240 """ | 241 """ |
| 241 self._log.assertMessages(messages) | 242 self._log.assertMessages(messages) |
| OLD | NEW |