OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
3 # for details. All rights reserved. Use of this source code is governed by a | |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | |
6 """Tests for emitter module.""" | |
7 | |
8 import logging.config | |
9 import unittest | |
10 import emitter | |
11 import multiemitter | |
12 | |
13 | |
14 class MultiEmitterTestCase(unittest.TestCase): | |
15 | |
16 def setUp(self): | |
17 pass | |
18 | |
19 def tearDown(self): | |
20 pass | |
21 | |
22 def check(self, m, expected): | |
23 """Verifies that the multiemitter contains the expected contents. | |
24 | |
25 Expected is a list of (filename, content) pairs, sorted by filename. | |
26 """ | |
27 files = [] | |
28 def _Collect(file, contents): | |
29 files.append((file, ''.join(contents))) | |
30 m.Flush(_Collect) | |
31 self.assertEquals(expected, files) | |
32 | |
33 def testExample(self): | |
34 m = multiemitter.MultiEmitter() | |
35 e1 = m.FileEmitter('file1') | |
36 e2 = m.FileEmitter('file2', 'key2') | |
37 e1.Emit('Hi 1') | |
38 e2.Emit('Hi 2') | |
39 m.Find('key2').Emit('Bye 2') | |
40 self.check(m, | |
41 [('file1', 'Hi 1'), | |
42 ('file2', 'Hi 2Bye 2') ]) | |
43 | |
44 if __name__ == '__main__': | |
45 logging.config.fileConfig('logging.conf') | |
46 if __name__ == '__main__': | |
47 unittest.main() | |
OLD | NEW |