3 # test_codecencodings_cn.py
4 # Codec encoding tests for PRC encodings.
7 from test
import test_support
8 from test
import test_multibytecodec_support
11 class Test_GB2312(test_multibytecodec_support
.TestBase
, unittest
.TestCase
):
13 tstring
= test_multibytecodec_support
.load_teststring('gb2312')
16 ("abc\x81\x81\xc1\xc4", "strict", None),
17 ("abc\xc8", "strict", None),
18 ("abc\x81\x81\xc1\xc4", "replace", u
"abc\ufffd\u804a"),
19 ("abc\x81\x81\xc1\xc4\xc8", "replace", u
"abc\ufffd\u804a\ufffd"),
20 ("abc\x81\x81\xc1\xc4", "ignore", u
"abc\u804a"),
21 ("\xc1\x64", "strict", None),
24 class Test_GBK(test_multibytecodec_support
.TestBase
, unittest
.TestCase
):
26 tstring
= test_multibytecodec_support
.load_teststring('gbk')
29 ("abc\x80\x80\xc1\xc4", "strict", None),
30 ("abc\xc8", "strict", None),
31 ("abc\x80\x80\xc1\xc4", "replace", u
"abc\ufffd\u804a"),
32 ("abc\x80\x80\xc1\xc4\xc8", "replace", u
"abc\ufffd\u804a\ufffd"),
33 ("abc\x80\x80\xc1\xc4", "ignore", u
"abc\u804a"),
34 ("\x83\x34\x83\x31", "strict", None),
35 (u
"\u30fb", "strict", None),
38 class Test_GB18030(test_multibytecodec_support
.TestBase
, unittest
.TestCase
):
40 tstring
= test_multibytecodec_support
.load_teststring('gb18030')
43 ("abc\x80\x80\xc1\xc4", "strict", None),
44 ("abc\xc8", "strict", None),
45 ("abc\x80\x80\xc1\xc4", "replace", u
"abc\ufffd\u804a"),
46 ("abc\x80\x80\xc1\xc4\xc8", "replace", u
"abc\ufffd\u804a\ufffd"),
47 ("abc\x80\x80\xc1\xc4", "ignore", u
"abc\u804a"),
48 ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u
"abc\ufffd\u804a"),
49 (u
"\u30fb", "strict", "\x819\xa79"),
54 test_support
.run_unittest(__name__
)
56 if __name__
== "__main__":