Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/fix_encoding_test.py

Issue 6721029: Fix locale.getlocale() exception. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « presubmit_support.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # coding=utf8
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
5 # found in the LICENSE file.
6
7 """Unit tests for fix_encoding.py."""
8
9 import os
10 import sys
11 import unittest
12
13 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
14 sys.path.insert(0, ROOT_DIR)
15
16 import fix_encoding
17
18
19 class FixEncodingTest(unittest.TestCase):
20 # Nice mix of latin, hebrew, arabic and chinese. Doesn't mean anything.
21 text = u'Héllô 偉大 سيد'
22
23 def test_code_page(self):
24 # Make sure printing garbage won't throw.
25 print self.text.encode() + '\xff'
26 print >> sys.stderr, self.text.encode() + '\xff'
27
28 def test_utf8(self):
29 # Make sure printing utf-8 works.
30 print self.text.encode('utf-8')
31 print >> sys.stderr, self.text.encode('utf-8')
32
33 def test_unicode(self):
34 # Make sure printing unicode works.
35 print self.text
36 print >> sys.stderr, self.text
37
38 def test_default_encoding(self):
39 self.assertEquals('utf-8', sys.getdefaultencoding())
40
41 def test_win_console(self):
42 if sys.platform != 'win32':
43 return
44 # This should fail if redirected. Can be checked with:
45 # python fix_encoding_test.py > a
46 self.assertEquals(
47 sys.stdout.__class__, fix_encoding.WinUnicodeConsoleOutput)
48 self.assertEquals(
49 sys.stderr.__class__, fix_encoding.WinUnicodeConsoleOutput)
50 self.assertEquals(sys.stdout.encoding, sys.getdefaultencoding())
51 self.assertEquals(sys.stderr.encoding, sys.getdefaultencoding())
52
53 def test_multiple_calls(self):
54 # Shouldn't do anything.
55 self.assertEquals(False, fix_encoding.fix_encoding())
56
57
58 if __name__ == '__main__':
59 assert fix_encoding.fix_encoding()
60 unittest.main()
OLDNEW
« no previous file with comments | « presubmit_support.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698