Home | History | Annotate | Download | only in test
      1 #!/usr/bin/env python
      2 #
      3 # test_codecmaps_jp.py
      4 #   Codec mapping tests for Japanese encodings
      5 #
      6 
      7 from test import test_support
      8 from test import test_multibytecodec_support
      9 import unittest
     10 
     11 class TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
     12                    unittest.TestCase):
     13     encoding = 'cp932'
     14     mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \
     15                  'WINDOWS/CP932.TXT'
     16     supmaps = [
     17         ('\x80', u'\u0080'),
     18         ('\xa0', u'\uf8f0'),
     19         ('\xfd', u'\uf8f1'),
     20         ('\xfe', u'\uf8f2'),
     21         ('\xff', u'\uf8f3'),
     22     ]
     23     for i in range(0xa1, 0xe0):
     24         supmaps.append((chr(i), unichr(i+0xfec0)))
     25 
     26 
     27 class TestEUCJPCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
     28                          unittest.TestCase):
     29     encoding = 'euc_jp'
     30     mapfilename = 'EUC-JP.TXT'
     31     mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT'
     32 
     33 
     34 class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
     35                         unittest.TestCase):
     36     encoding = 'shift_jis'
     37     mapfilename = 'SHIFTJIS.TXT'
     38     mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \
     39                  '/EASTASIA/JIS/SHIFTJIS.TXT'
     40     pass_enctest = [
     41         ('\x81_', u'\\'),
     42     ]
     43     pass_dectest = [
     44         ('\\', u'\xa5'),
     45         ('~', u'\u203e'),
     46         ('\x81_', u'\\'),
     47     ]
     48 
     49 class TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
     50                          unittest.TestCase):
     51     encoding = 'euc_jisx0213'
     52     mapfilename = 'EUC-JISX0213.TXT'
     53     mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT'
     54 
     55 
     56 class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
     57                        unittest.TestCase):
     58     encoding = 'shift_jisx0213'
     59     mapfilename = 'SHIFT_JISX0213.TXT'
     60     mapfileurl = 'http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT'
     61 
     62 
     63 def test_main():
     64     test_support.run_unittest(__name__)
     65 
     66 if __name__ == "__main__":
     67     test_main()
     68