OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding=utf8 | 2 # coding=utf8 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Unit tests for fix_encoding.py.""" | 7 """Unit tests for fix_encoding.py.""" |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 23 matching lines...) Expand all Loading... |
34 # Make sure printing unicode works. | 34 # Make sure printing unicode works. |
35 print self.text | 35 print self.text |
36 print >> sys.stderr, self.text | 36 print >> sys.stderr, self.text |
37 | 37 |
38 def test_default_encoding(self): | 38 def test_default_encoding(self): |
39 self.assertEquals('utf-8', sys.getdefaultencoding()) | 39 self.assertEquals('utf-8', sys.getdefaultencoding()) |
40 | 40 |
41 def test_win_console(self): | 41 def test_win_console(self): |
42 if sys.platform != 'win32': | 42 if sys.platform != 'win32': |
43 return | 43 return |
44 # This should fail if redirected. Can be checked with: | 44 # This should fail if not redirected, e.g. run directly instead of through |
45 # python fix_encoding_test.py > a | 45 # the presubmit check. Can be checked with: |
| 46 # python tests\fix_encoding_test.py |
46 self.assertEquals( | 47 self.assertEquals( |
47 sys.stdout.__class__, fix_encoding.WinUnicodeConsoleOutput) | 48 sys.stdout.__class__, fix_encoding.WinUnicodeOutput) |
48 self.assertEquals( | 49 self.assertEquals( |
49 sys.stderr.__class__, fix_encoding.WinUnicodeConsoleOutput) | 50 sys.stderr.__class__, fix_encoding.WinUnicodeOutput) |
50 self.assertEquals(sys.stdout.encoding, sys.getdefaultencoding()) | 51 self.assertEquals(sys.stdout.encoding, sys.getdefaultencoding()) |
51 self.assertEquals(sys.stderr.encoding, sys.getdefaultencoding()) | 52 self.assertEquals(sys.stderr.encoding, sys.getdefaultencoding()) |
52 | 53 |
53 def test_multiple_calls(self): | 54 def test_multiple_calls(self): |
54 # Shouldn't do anything. | 55 # Shouldn't do anything. |
55 self.assertEquals(False, fix_encoding.fix_encoding()) | 56 self.assertEquals(False, fix_encoding.fix_encoding()) |
56 | 57 |
57 | 58 |
58 if __name__ == '__main__': | 59 if __name__ == '__main__': |
59 assert fix_encoding.fix_encoding() | 60 assert fix_encoding.fix_encoding() |
60 unittest.main() | 61 unittest.main() |
OLD | NEW |