0001 #!/usr/bin/env python 0002 # 0003 # test_codecencodings_kr.py 0004 # Codec encoding tests for ROK encodings. 0005 # 0006 # $CJKCodecs: test_codecencodings_kr.py,v 1.2 2004/06/19 06:09:55 perky Exp $ 0007 0008 from test import test_support 0009 from test import test_multibytecodec_support 0010 import unittest 0011 0012 class Test_CP949(test_multibytecodec_support.TestBase, unittest.TestCase): 0013 encoding = 'cp949' 0014 tstring = test_multibytecodec_support.load_teststring('cp949') 0015 codectests = ( 0016 # invalid bytes 0017 ("abc\x80\x80\xc1\xc4", "strict", None), 0018 ("abc\xc8", "strict", None), 0019 ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"), 0020 ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"), 0021 ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"), 0022 ) 0023 0024 class Test_EUCKR(test_multibytecodec_support.TestBase, unittest.TestCase): 0025 encoding = 'euc_kr' 0026 tstring = test_multibytecodec_support.load_teststring('euc_kr') 0027 codectests = ( 0028 # invalid bytes 0029 ("abc\x80\x80\xc1\xc4", "strict", None), 0030 ("abc\xc8", "strict", None), 0031 ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"), 0032 ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"), 0033 ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"), 0034 ) 0035 0036 class Test_JOHAB(test_multibytecodec_support.TestBase, unittest.TestCase): 0037 encoding = 'johab' 0038 tstring = test_multibytecodec_support.load_teststring('johab') 0039 codectests = ( 0040 # invalid bytes 0041 ("abc\x80\x80\xc1\xc4", "strict", None), 0042 ("abc\xc8", "strict", None), 0043 ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\ucd27"), 0044 ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\ucd27\ufffd"), 0045 ("abc\x80\x80\xc1\xc4", "ignore", u"abc\ucd27"), 0046 ) 0047 0048 def test_main(): 0049 suite = unittest.TestSuite() 0050 suite.addTest(unittest.makeSuite(Test_CP949)) 0051 suite.addTest(unittest.makeSuite(Test_EUCKR)) 0052 suite.addTest(unittest.makeSuite(Test_JOHAB)) 0053 test_support.run_suite(suite) 0054 0055 if __name__ == "__main__": 0056 test_main() 0057
Generated by PyXR 0.9.4