Home | History | Annotate | Download | only in test
      1 # Codec encoding tests for ISO 2022 encodings.
      2 
      3 from test import test_support
      4 from test import test_multibytecodec_support
      5 import unittest
      6 
      7 COMMON_CODEC_TESTS = (
      8         # invalid bytes
      9         (b'ab\xFFcd', 'replace', u'ab\uFFFDcd'),
     10         (b'ab\x1Bdef', 'replace', u'ab\x1Bdef'),
     11         (b'ab\x1B$def', 'replace', u'ab\uFFFD'),
     12     )
     13 
     14 class Test_ISO2022_JP(test_multibytecodec_support.TestBase, unittest.TestCase):
     15     encoding = 'iso2022_jp'
     16     tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
     17     codectests = COMMON_CODEC_TESTS + (
     18         (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
     19     )
     20 
     21 class Test_ISO2022_JP2(test_multibytecodec_support.TestBase, unittest.TestCase):
     22     encoding = 'iso2022_jp_2'
     23     tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
     24     codectests = COMMON_CODEC_TESTS + (
     25         (b'ab\x1BNdef', 'replace', u'abdef'),
     26     )
     27 
     28 class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
     29     encoding = 'iso2022_kr'
     30     tstring = test_multibytecodec_support.load_teststring('iso2022_kr')
     31     codectests = COMMON_CODEC_TESTS + (
     32         (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
     33     )
     34 
     35     # iso2022_kr.txt cannot be used to test "chunk coding": the escape
     36     # sequence is only written on the first line
     37     @unittest.skip('iso2022_kr.txt cannot be used to test "chunk coding"')
     38     def test_chunkcoding(self):
     39         pass
     40 
     41 def test_main():
     42     test_support.run_unittest(__name__)
     43 
     44 if __name__ == "__main__":
     45     test_main()
     46