test_codecencodings_iso2022.py 1.4 KB

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