| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import itertools | 6 import itertools |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return test_log | 43 return test_log |
| 44 | 44 |
| 45 def assertIterEqual(self, expected_iter, actual_iter): | 45 def assertIterEqual(self, expected_iter, actual_iter): |
| 46 for expected, actual in itertools.izip_longest(expected_iter, actual_iter): | 46 for expected, actual in itertools.izip_longest(expected_iter, actual_iter): |
| 47 self.assertIsNotNone( | 47 self.assertIsNotNone( |
| 48 expected, | 48 expected, |
| 49 msg='actual has unexpected elements starting with %s' % str(actual)) | 49 msg='actual has unexpected elements starting with %s' % str(actual)) |
| 50 self.assertIsNotNone( | 50 self.assertIsNotNone( |
| 51 actual, | 51 actual, |
| 52 msg='actual is missing elements starting with %s' % str(expected)) | 52 msg='actual is missing elements starting with %s' % str(expected)) |
| 53 self.assertEqual(actual.proc_id, expected[0]) | 53 self.assertEqual(actual.group('proc_id'), expected[0]) |
| 54 self.assertEqual(actual.thread_id, expected[1]) | 54 self.assertEqual(actual.group('thread_id'), expected[1]) |
| 55 self.assertEqual(actual.log_level, expected[2]) | 55 self.assertEqual(actual.group('log_level'), expected[2]) |
| 56 self.assertEqual(actual.component, expected[3]) | 56 self.assertEqual(actual.group('component'), expected[3]) |
| 57 self.assertEqual(actual.message, expected[4]) | 57 self.assertEqual(actual.group('message'), expected[4]) |
| 58 | 58 |
| 59 with self.assertRaises(StopIteration): | 59 with self.assertRaises(StopIteration): |
| 60 next(actual_iter) | 60 next(actual_iter) |
| 61 with self.assertRaises(StopIteration): | 61 with self.assertRaises(StopIteration): |
| 62 next(expected_iter) | 62 next(expected_iter) |
| 63 | 63 |
| 64 def testWaitFor_success(self): | 64 def testWaitFor_success(self): |
| 65 test_log = self._createTestLog( | 65 test_log = self._createTestLog( |
| 66 raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA) | 66 raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA) |
| 67 actual_match = test_log.WaitFor(r'.*(fatal|error) logcat monitor.*', None) | 67 actual_match = test_log.WaitFor(r'.*(fatal|error) logcat monitor.*', None) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 ('2345', '5432', 'F', 'LogcatMonitorTest', | 155 ('2345', '5432', 'F', 'LogcatMonitorTest', |
| 156 'fatal logcat monitor test message 6'), | 156 'fatal logcat monitor test message 6'), |
| 157 ('3456', '6543', 'D', 'LogcatMonitorTest', | 157 ('3456', '6543', 'D', 'LogcatMonitorTest', |
| 158 'ignore me'),] | 158 'ignore me'),] |
| 159 self.assertIterEqual(iter(expected_results), actual_results) | 159 self.assertIterEqual(iter(expected_results), actual_results) |
| 160 | 160 |
| 161 | 161 |
| 162 if __name__ == '__main__': | 162 if __name__ == '__main__': |
| 163 unittest.main(verbosity=2) | 163 unittest.main(verbosity=2) |
| 164 | 164 |
| OLD | NEW |