Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Side by Side Diff: Lib/test/test_codecencodings_jp.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_codecencodings_hk.py ('k') | Lib/test/test_codecencodings_kr.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 # 2 #
3 # test_codecencodings_jp.py 3 # test_codecencodings_jp.py
4 # Codec encoding tests for Japanese encodings. 4 # Codec encoding tests for Japanese encodings.
5 # 5 #
6 6
7 from test import support 7 from test import support
8 from test import test_multibytecodec_support 8 from test import test_multibytecodec_support
9 import unittest 9 import unittest
10 10
11 class Test_CP932(test_multibytecodec_support.TestBase, unittest.TestCase): 11 class Test_CP932(test_multibytecodec_support.TestBase, unittest.TestCase):
12 encoding = 'cp932' 12 encoding = 'cp932'
13 tstring = test_multibytecodec_support.load_teststring('shift_jis') 13 tstring = test_multibytecodec_support.load_teststring('shift_jis')
14 codectests = ( 14 codectests = (
15 # invalid bytes 15 # invalid bytes
16 (b"abc\x81\x00\x81\x00\x82\x84", "strict", None), 16 (b"abc\x81\x00\x81\x00\x82\x84", "strict", None),
17 (b"abc\xf8", "strict", None), 17 (b"abc\xf8", "strict", None),
18 (b"abc\x81\x00\x82\x84", "replace", "abc\ufffd\x00\uff44"), 18 (b"abc\x81\x00\x82\x84", "replace", "abc\ufffd\uff44"),
19 (b"abc\x81\x00\x82\x84\x88", "replace", "abc\ufffd\x00\uff44\ufffd"), 19 (b"abc\x81\x00\x82\x84\x88", "replace", "abc\ufffd\uff44\ufffd"),
20 (b"abc\x81\x00\x82\x84", "ignore", "abc\x00\uff44"), 20 (b"abc\x81\x00\x82\x84", "ignore", "abc\uff44"),
21 (b"ab\xEBxy", "replace", "ab\uFFFDxy"),
22 (b"ab\xF0\x39xy", "replace", "ab\uFFFD9xy"),
23 (b"ab\xEA\xF0xy", "replace", 'ab\ufffd\ue038y'),
24 # sjis vs cp932 21 # sjis vs cp932
25 (b"\\\x7e", "replace", "\\\x7e"), 22 (b"\\\x7e", "replace", "\\\x7e"),
26 (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\uff3c\u2225\uff0d"), 23 (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\uff3c\u2225\uff0d"),
27 )
28
29 euc_commontests = (
30 # invalid bytes
31 (b"abc\x80\x80\xc1\xc4", "strict", None),
32 (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\u7956"),
33 (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\u7956\ufffd"),
34 (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u7956"),
35 (b"abc\xc8", "strict", None),
36 (b"abc\x8f\x83\x83", "replace", "abc\ufffd\ufffd\ufffd"),
37 (b"\x82\xFCxy", "replace", "\ufffd\ufffdxy"),
38 (b"\xc1\x64", "strict", None),
39 (b"\xa1\xc0", "strict", "\uff3c"),
40 (b"\xa1\xc0\\", "strict", "\uff3c\\"),
41 (b"\x8eXY", "replace", "\ufffdXY"),
42 )
43
44 class Test_EUC_JIS_2004(test_multibytecodec_support.TestBase,
45 unittest.TestCase):
46 encoding = 'euc_jis_2004'
47 tstring = test_multibytecodec_support.load_teststring('euc_jisx0213')
48 codectests = euc_commontests
49 xmlcharnametest = (
50 "\xab\u211c\xbb = \u2329\u1234\u232a",
51 b"\xa9\xa8ℜ\xa9\xb2 = ⟨ሴ⟩"
52 ) 24 )
53 25
54 class Test_EUC_JISX0213(test_multibytecodec_support.TestBase, 26 class Test_EUC_JISX0213(test_multibytecodec_support.TestBase,
55 unittest.TestCase): 27 unittest.TestCase):
56 encoding = 'euc_jisx0213' 28 encoding = 'euc_jisx0213'
57 tstring = test_multibytecodec_support.load_teststring('euc_jisx0213') 29 tstring = test_multibytecodec_support.load_teststring('euc_jisx0213')
58 codectests = euc_commontests 30 codectests = (
31 # invalid bytes
32 (b"abc\x80\x80\xc1\xc4", "strict", None),
33 (b"abc\xc8", "strict", None),
34 (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u7956"),
35 (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u7956\ufffd"),
36 (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u7956"),
37 (b"abc\x8f\x83\x83", "replace", "abc\ufffd"),
38 (b"\xc1\x64", "strict", None),
39 (b"\xa1\xc0", "strict", "\uff3c"),
40 )
59 xmlcharnametest = ( 41 xmlcharnametest = (
60 "\xab\u211c\xbb = \u2329\u1234\u232a", 42 "\xab\u211c\xbb = \u2329\u1234\u232a",
61 b"\xa9\xa8ℜ\xa9\xb2 = ⟨ሴ⟩" 43 b"\xa9\xa8ℜ\xa9\xb2 = ⟨ሴ⟩"
62 ) 44 )
63 45
46 eucjp_commontests = (
47 (b"abc\x80\x80\xc1\xc4", "strict", None),
48 (b"abc\xc8", "strict", None),
49 (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u7956"),
50 (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u7956\ufffd"),
51 (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u7956"),
52 (b"abc\x8f\x83\x83", "replace", "abc\ufffd"),
53 (b"\xc1\x64", "strict", None),
54 )
55
64 class Test_EUC_JP_COMPAT(test_multibytecodec_support.TestBase, 56 class Test_EUC_JP_COMPAT(test_multibytecodec_support.TestBase,
65 unittest.TestCase): 57 unittest.TestCase):
66 encoding = 'euc_jp' 58 encoding = 'euc_jp'
67 tstring = test_multibytecodec_support.load_teststring('euc_jp') 59 tstring = test_multibytecodec_support.load_teststring('euc_jp')
68 codectests = euc_commontests + ( 60 codectests = eucjp_commontests + (
61 (b"\xa1\xc0\\", "strict", "\uff3c\\"),
69 ("\xa5", "strict", b"\x5c"), 62 ("\xa5", "strict", b"\x5c"),
70 ("\u203e", "strict", b"\x7e"), 63 ("\u203e", "strict", b"\x7e"),
71 ) 64 )
72 65
73 shiftjis_commonenctests = ( 66 shiftjis_commonenctests = (
74 (b"abc\x80\x80\x82\x84", "strict", None), 67 (b"abc\x80\x80\x82\x84", "strict", None),
75 (b"abc\xf8", "strict", None), 68 (b"abc\xf8", "strict", None),
69 (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\uff44"),
70 (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\uff44\ufffd"),
76 (b"abc\x80\x80\x82\x84def", "ignore", "abc\uff44def"), 71 (b"abc\x80\x80\x82\x84def", "ignore", "abc\uff44def"),
77 ) 72 )
78 73
79 class Test_SJIS_COMPAT(test_multibytecodec_support.TestBase, unittest.TestCase): 74 class Test_SJIS_COMPAT(test_multibytecodec_support.TestBase, unittest.TestCase):
80 encoding = 'shift_jis' 75 encoding = 'shift_jis'
81 tstring = test_multibytecodec_support.load_teststring('shift_jis') 76 tstring = test_multibytecodec_support.load_teststring('shift_jis')
82 codectests = shiftjis_commonenctests + ( 77 codectests = shiftjis_commonenctests + (
83 (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\ufffd\uff44"),
84 (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\ufffd\uff44\ufffd"),
85
86 (b"\\\x7e", "strict", "\\\x7e"), 78 (b"\\\x7e", "strict", "\\\x7e"),
87 (b"\x81\x5f\x81\x61\x81\x7c", "strict", "\uff3c\u2016\u2212"), 79 (b"\x81\x5f\x81\x61\x81\x7c", "strict", "\uff3c\u2016\u2212"),
88 (b"abc\x81\x39", "replace", "abc\ufffd9"),
89 (b"abc\xEA\xFC", "replace", "abc\ufffd\ufffd"),
90 (b"abc\xFF\x58", "replace", "abc\ufffdX"),
91 )
92
93 class Test_SJIS_2004(test_multibytecodec_support.TestBase, unittest.TestCase):
94 encoding = 'shift_jis_2004'
95 tstring = test_multibytecodec_support.load_teststring('shift_jis')
96 codectests = shiftjis_commonenctests + (
97 (b"\\\x7e", "strict", "\xa5\u203e"),
98 (b"\x81\x5f\x81\x61\x81\x7c", "strict", "\\\u2016\u2212"),
99 (b"abc\xEA\xFC", "strict", "abc\u64bf"),
100 (b"\x81\x39xy", "replace", "\ufffd9xy"),
101 (b"\xFF\x58xy", "replace", "\ufffdXxy"),
102 (b"\x80\x80\x82\x84xy", "replace", "\ufffd\ufffd\uff44xy"),
103 (b"\x80\x80\x82\x84\x88xy", "replace", "\ufffd\ufffd\uff44\u5864y"),
104 (b"\xFC\xFBxy", "replace", '\ufffd\u95b4y'),
105 )
106 xmlcharnametest = (
107 "\xab\u211c\xbb = \u2329\u1234\u232a",
108 b"\x85Gℜ\x85Q = ⟨ሴ⟩"
109 ) 80 )
110 81
111 class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase): 82 class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase):
112 encoding = 'shift_jisx0213' 83 encoding = 'shift_jisx0213'
113 tstring = test_multibytecodec_support.load_teststring('shift_jisx0213') 84 tstring = test_multibytecodec_support.load_teststring('shift_jisx0213')
114 codectests = shiftjis_commonenctests + ( 85 codectests = (
115 (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\ufffd\uff44"), 86 # invalid bytes
116 (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\ufffd\uff44\ufffd"), 87 (b"abc\x80\x80\x82\x84", "strict", None),
117 88 (b"abc\xf8", "strict", None),
89 (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\uff44"),
90 (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\uff44\ufffd"),
91 (b"abc\x80\x80\x82\x84def", "ignore", "abc\uff44def"),
118 # sjis vs cp932 92 # sjis vs cp932
119 (b"\\\x7e", "replace", "\xa5\u203e"), 93 (b"\\\x7e", "replace", "\xa5\u203e"),
120 (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\x5c\u2016\u2212"), 94 (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\x5c\u2016\u2212"),
121 ) 95 )
122 xmlcharnametest = ( 96 xmlcharnametest = (
123 "\xab\u211c\xbb = \u2329\u1234\u232a", 97 "\xab\u211c\xbb = \u2329\u1234\u232a",
124 b"\x85Gℜ\x85Q = ⟨ሴ⟩" 98 b"\x85Gℜ\x85Q = ⟨ሴ⟩"
125 ) 99 )
126 100
127 def test_main(): 101 def test_main():
128 support.run_unittest(__name__) 102 support.run_unittest(__name__)
129 103
130 if __name__ == "__main__": 104 if __name__ == "__main__":
131 test_main() 105 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_codecencodings_hk.py ('k') | Lib/test/test_codecencodings_kr.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+