| OLD | NEW |
| 1 # Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2010, 2012 Google Inc. All rights reserved. |
| 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 are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return self.buflist | 100 return self.buflist |
| 101 | 101 |
| 102 def test_log_after_update(self): | 102 def test_log_after_update(self): |
| 103 buflist = self._log_after_update() | 103 buflist = self._log_after_update() |
| 104 self.assertEqual(buflist, ['foo\n', 'bar\n']) | 104 self.assertEqual(buflist, ['foo\n', 'bar\n']) |
| 105 | 105 |
| 106 def test_log_args(self): | 106 def test_log_args(self): |
| 107 self.logger.info('foo %s %d', 'bar', 2) | 107 self.logger.info('foo %s %d', 'bar', 2) |
| 108 self.assertEqual(self.buflist, ['foo bar 2\n']) | 108 self.assertEqual(self.buflist, ['foo bar 2\n']) |
| 109 | 109 |
| 110 |
| 110 class TtyTest(RegularTest): | 111 class TtyTest(RegularTest): |
| 111 verbose = False | 112 verbose = False |
| 112 isatty = True | 113 isatty = True |
| 113 | 114 |
| 114 def test_basic(self): | 115 def test_basic(self): |
| 115 buflist = self._basic([0, 1, 1.05, 1.1, 2]) | 116 buflist = self._basic([0, 1, 1.05, 1.1, 2]) |
| 116 self.assertEqual(buflist, ['foo', | 117 self.assertEqual(buflist, ['foo', |
| 117 MeteredStream._erasure('foo'), 'bar', | 118 MeteredStream._erasure('foo'), 'bar', |
| 118 MeteredStream._erasure('bar'), 'baz 2', | 119 MeteredStream._erasure('bar'), 'baz 2', |
| 119 MeteredStream._erasure('baz 2'), 'done\n']) | 120 MeteredStream._erasure('baz 2'), 'done\n']) |
| 120 | 121 |
| 121 def test_log_after_update(self): | 122 def test_log_after_update(self): |
| 122 buflist = self._log_after_update() | 123 buflist = self._log_after_update() |
| 123 self.assertEqual(buflist, ['foo', | 124 self.assertEqual(buflist, ['foo', |
| 124 MeteredStream._erasure('foo'), 'bar\n']) | 125 MeteredStream._erasure('foo'), 'bar\n']) |
| 125 | 126 |
| 126 | 127 |
| 127 class VerboseTest(RegularTest): | 128 class VerboseTest(RegularTest): |
| 128 isatty = False | 129 isatty = False |
| 129 verbose = True | 130 verbose = True |
| 130 | 131 |
| 131 def test_basic(self): | 132 def test_basic(self): |
| 132 buflist = self._basic([0, 1, 2.1, 13, 14.1234]) | 133 buflist = self._basic([0, 1, 2.1, 13, 14.1234]) |
| 133 # We don't bother to match the hours and minutes of the timestamp since | 134 # We don't bother to match the hours and minutes of the timestamp since |
| 134 # the local timezone can vary and we can't set that portably and easily. | 135 # the local timezone can vary and we can't set that portably and easily. |
| 135 self.assertTrue(re.match('\d\d:\d\d:00.000 8675 foo\n', buflist[0])) | 136 self.assertTrue(re.match('\d\d:\d\d:00.000 8675 foo\n', buflist[0])) |
| 136 self.assertTrue(re.match('\d\d:\d\d:01.000 8675 bar\n', buflist[1])) | 137 self.assertTrue(re.match('\d\d:\d\d:01.000 8675 bar\n', buflist[1])) |
| 137 self.assertTrue(re.match('\d\d:\d\d:13.000 8675 baz 2\n', buflist[2])) | 138 self.assertTrue(re.match('\d\d:\d\d:13.000 8675 baz 2\n', buflist[2])) |
| 138 self.assertTrue(re.match('\d\d:\d\d:14.123 8675 done\n', buflist[3])) | 139 self.assertTrue(re.match('\d\d:\d\d:14.123 8675 done\n', buflist[3])) |
| 139 self.assertEqual(len(buflist), 4) | 140 self.assertEqual(len(buflist), 4) |
| 140 | 141 |
| 141 def test_log_after_update(self): | 142 def test_log_after_update(self): |
| 142 buflist = self._log_after_update() | 143 buflist = self._log_after_update() |
| 143 self.assertTrue(re.match('\d\d:\d\d:00.000 8675 foo\n', buflist[0])) | 144 self.assertTrue(re.match('\d\d:\d\d:00.000 8675 foo\n', buflist[0])) |
| 144 | 145 |
| 145 # The second argument should have a real timestamp and pid, so we just c
heck the format. | 146 # The second argument should have a real timestamp and pid, so we just c
heck the format. |
| 146 self.assertTrue(re.match('\d\d:\d\d:\d\d.\d\d\d \d+ bar\n', buflist[1])) | 147 self.assertTrue(re.match('\d\d:\d\d:\d\d.\d\d\d \d+ bar\n', buflist[1])) |
| 147 | 148 |
| 148 self.assertEqual(len(buflist), 2) | 149 self.assertEqual(len(buflist), 2) |
| 149 | 150 |
| 150 def test_log_args(self): | 151 def test_log_args(self): |
| 151 self.logger.info('foo %s %d', 'bar', 2) | 152 self.logger.info('foo %s %d', 'bar', 2) |
| 152 self.assertEqual(len(self.buflist), 1) | 153 self.assertEqual(len(self.buflist), 1) |
| 153 self.assertTrue(self.buflist[0].endswith('foo bar 2\n')) | 154 self.assertTrue(self.buflist[0].endswith('foo bar 2\n')) |
| OLD | NEW |