+++ /dev/null
-#!/usr/bin/env python\r
-#\r
-# test_codecencodings_jp.py\r
-# Codec encoding tests for Japanese encodings.\r
-#\r
-\r
-from test import test_support\r
-from test import test_multibytecodec_support\r
-import unittest\r
-\r
-class Test_CP932(test_multibytecodec_support.TestBase, unittest.TestCase):\r
- encoding = 'cp932'\r
- tstring = test_multibytecodec_support.load_teststring('shift_jis')\r
- codectests = (\r
- # invalid bytes\r
- ("abc\x81\x00\x81\x00\x82\x84", "strict", None),\r
- ("abc\xf8", "strict", None),\r
- ("abc\x81\x00\x82\x84", "replace", u"abc\ufffd\uff44"),\r
- ("abc\x81\x00\x82\x84\x88", "replace", u"abc\ufffd\uff44\ufffd"),\r
- ("abc\x81\x00\x82\x84", "ignore", u"abc\uff44"),\r
- # sjis vs cp932\r
- ("\\\x7e", "replace", u"\\\x7e"),\r
- ("\x81\x5f\x81\x61\x81\x7c", "replace", u"\uff3c\u2225\uff0d"),\r
- )\r
-\r
-class Test_EUC_JISX0213(test_multibytecodec_support.TestBase,\r
- unittest.TestCase):\r
- encoding = 'euc_jisx0213'\r
- tstring = test_multibytecodec_support.load_teststring('euc_jisx0213')\r
- codectests = (\r
- # invalid bytes\r
- ("abc\x80\x80\xc1\xc4", "strict", None),\r
- ("abc\xc8", "strict", None),\r
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u7956"),\r
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u7956\ufffd"),\r
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u7956"),\r
- ("abc\x8f\x83\x83", "replace", u"abc\ufffd"),\r
- ("\xc1\x64", "strict", None),\r
- ("\xa1\xc0", "strict", u"\uff3c"),\r
- )\r
- xmlcharnametest = (\r
- u"\xab\u211c\xbb = \u2329\u1234\u232a",\r
- "\xa9\xa8ℜ\xa9\xb2 = ⟨ሴ⟩"\r
- )\r
-\r
-eucjp_commontests = (\r
- ("abc\x80\x80\xc1\xc4", "strict", None),\r
- ("abc\xc8", "strict", None),\r
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u7956"),\r
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u7956\ufffd"),\r
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u7956"),\r
- ("abc\x8f\x83\x83", "replace", u"abc\ufffd"),\r
- ("\xc1\x64", "strict", None),\r
-)\r
-\r
-class Test_EUC_JP_COMPAT(test_multibytecodec_support.TestBase,\r
- unittest.TestCase):\r
- encoding = 'euc_jp'\r
- tstring = test_multibytecodec_support.load_teststring('euc_jp')\r
- codectests = eucjp_commontests + (\r
- ("\xa1\xc0\\", "strict", u"\uff3c\\"),\r
- (u"\xa5", "strict", "\x5c"),\r
- (u"\u203e", "strict", "\x7e"),\r
- )\r
-\r
-shiftjis_commonenctests = (\r
- ("abc\x80\x80\x82\x84", "strict", None),\r
- ("abc\xf8", "strict", None),\r
- ("abc\x80\x80\x82\x84", "replace", u"abc\ufffd\uff44"),\r
- ("abc\x80\x80\x82\x84\x88", "replace", u"abc\ufffd\uff44\ufffd"),\r
- ("abc\x80\x80\x82\x84def", "ignore", u"abc\uff44def"),\r
-)\r
-\r
-class Test_SJIS_COMPAT(test_multibytecodec_support.TestBase, unittest.TestCase):\r
- encoding = 'shift_jis'\r
- tstring = test_multibytecodec_support.load_teststring('shift_jis')\r
- codectests = shiftjis_commonenctests + (\r
- ("\\\x7e", "strict", u"\\\x7e"),\r
- ("\x81\x5f\x81\x61\x81\x7c", "strict", u"\uff3c\u2016\u2212"),\r
- )\r
-\r
-class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase):\r
- encoding = 'shift_jisx0213'\r
- tstring = test_multibytecodec_support.load_teststring('shift_jisx0213')\r
- codectests = (\r
- # invalid bytes\r
- ("abc\x80\x80\x82\x84", "strict", None),\r
- ("abc\xf8", "strict", None),\r
- ("abc\x80\x80\x82\x84", "replace", u"abc\ufffd\uff44"),\r
- ("abc\x80\x80\x82\x84\x88", "replace", u"abc\ufffd\uff44\ufffd"),\r
- ("abc\x80\x80\x82\x84def", "ignore", u"abc\uff44def"),\r
- # sjis vs cp932\r
- ("\\\x7e", "replace", u"\xa5\u203e"),\r
- ("\x81\x5f\x81\x61\x81\x7c", "replace", u"\x5c\u2016\u2212"),\r
- )\r
- xmlcharnametest = (\r
- u"\xab\u211c\xbb = \u2329\u1234\u232a",\r
- "\x85Gℜ\x85Q = ⟨ሴ⟩"\r
- )\r
-\r
-def test_main():\r
- test_support.run_unittest(__name__)\r
-\r
-if __name__ == "__main__":\r
- test_main()\r