• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Codec encoding tests for ISO 2022 encodings.
2
3from test import test_support
4from test import multibytecodec_support
5import unittest
6
7COMMON_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
14class Test_ISO2022_JP(multibytecodec_support.TestBase, unittest.TestCase):
15    encoding = 'iso2022_jp'
16    tstring = multibytecodec_support.load_teststring('iso2022_jp')
17    codectests = COMMON_CODEC_TESTS + (
18        (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
19    )
20
21class Test_ISO2022_JP2(multibytecodec_support.TestBase, unittest.TestCase):
22    encoding = 'iso2022_jp_2'
23    tstring = multibytecodec_support.load_teststring('iso2022_jp')
24    codectests = COMMON_CODEC_TESTS + (
25        (b'ab\x1BNdef', 'replace', u'abdef'),
26    )
27
28class Test_ISO2022_KR(multibytecodec_support.TestBase, unittest.TestCase):
29    encoding = 'iso2022_kr'
30    tstring = 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
41def test_main():
42    test_support.run_unittest(__name__)
43
44if __name__ == "__main__":
45    test_main()
46