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