| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 logger=logger, | 80 logger=logger, |
| 81 stream=log_stream) | 81 stream=log_stream) |
| 82 self._log = logger | 82 self._log = logger |
| 83 self._log_stream = log_stream | 83 self._log_stream = log_stream |
| 84 | 84 |
| 85 def tearDown(self): | 85 def tearDown(self): |
| 86 """Reset logging to its original state. | 86 """Reset logging to its original state. |
| 87 | 87 |
| 88 This method ensures that the logging configuration set up | 88 This method ensures that the logging configuration set up |
| 89 for a unit test does not affect logging in other unit tests. | 89 for a unit test does not affect logging in other unit tests. |
| 90 | |
| 91 """ | 90 """ |
| 92 logger = self._log | 91 logger = self._log |
| 93 for handler in self._handlers: | 92 for handler in self._handlers: |
| 94 logger.removeHandler(handler) | 93 logger.removeHandler(handler) |
| 95 | 94 |
| 96 def _assert_log_messages(self, messages): | 95 def _assert_log_messages(self, messages): |
| 97 """Assert that the logged messages equal the given messages.""" | 96 """Assert that the logged messages equal the given messages.""" |
| 98 self._log_stream.assertMessages(messages) | 97 self._log_stream.assertMessages(messages) |
| 99 | 98 |
| 100 | 99 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 def _logging_level(self): | 150 def _logging_level(self): |
| 152 return self._level | 151 return self._level |
| 153 | 152 |
| 154 def test_logged_message(self): | 153 def test_logged_message(self): |
| 155 self._log.log(self._level, "test message") | 154 self._log.log(self._level, "test message") |
| 156 self._assert_log_messages(["test message\n"]) | 155 self._assert_log_messages(["test message\n"]) |
| 157 | 156 |
| 158 def test_below_threshold_message(self): | 157 def test_below_threshold_message(self): |
| 159 self._log.log(self._level - 1, "test message") | 158 self._log.log(self._level - 1, "test message") |
| 160 self._assert_log_messages([]) | 159 self._assert_log_messages([]) |
| OLD | NEW |