1 # Codec encoding tests for ISO 2022 encodings.
2
3 from test import multibytecodec_support
4 import unittest
5
6 COMMON_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
13 class ESC[4;38;5;81mTest_ISO2022_JP(ESC[4;38;5;149mmultibytecodec_supportESC[4;38;5;149m.ESC[4;38;5;149mTestBase, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
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
20 class ESC[4;38;5;81mTest_ISO2022_JP2(ESC[4;38;5;149mmultibytecodec_supportESC[4;38;5;149m.ESC[4;38;5;149mTestBase, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
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
27 class ESC[4;38;5;81mTest_ISO2022_KR(ESC[4;38;5;149mmultibytecodec_supportESC[4;38;5;149m.ESC[4;38;5;149mTestBase, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
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
40 if __name__ == "__main__":
41 unittest.main()