Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting.
[python.git] / Lib / test / test_codecencodings_cn.py
blob96b0d770969d17637780da1edcad620b700d58ad
1 #!/usr/bin/env python
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
9 import unittest
11 class Test_GB2312(test_multibytecodec_support.TestBase, unittest.TestCase):
12 encoding = 'gb2312'
13 tstring = test_multibytecodec_support.load_teststring('gb2312')
14 codectests = (
15 # invalid bytes
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):
25 encoding = 'gbk'
26 tstring = test_multibytecodec_support.load_teststring('gbk')
27 codectests = (
28 # invalid bytes
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):
39 encoding = 'gb18030'
40 tstring = test_multibytecodec_support.load_teststring('gb18030')
41 codectests = (
42 # invalid bytes
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"),
51 has_iso10646 = True
53 def test_main():
54 test_support.run_unittest(__name__)
56 if __name__ == "__main__":
57 test_main()