blob: 8c6e8a5965b1d0451b54e68709e50fa1af18373c [file] [log] [blame]
Victor Stinneree497972011-05-31 00:01:24 +02001#!/usr/bin/env python
2#
3# Codec encoding tests for ISO 2022 encodings.
4
5from test import support
6from test import test_multibytecodec_support
7import unittest
8
9COMMON_CODEC_TESTS = (
10 # invalid bytes
11 (b'ab\xFFcd', 'replace', 'ab\uFFFDcd'),
12 (b'ab\x1Bdef', 'replace', 'ab\x1Bdef'),
13 (b'ab\x1B$def', 'replace', 'ab\uFFFD'),
14 )
15
16class Test_ISO2022_JP(test_multibytecodec_support.TestBase, unittest.TestCase):
17 encoding = 'iso2022_jp'
18 tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
19 codectests = COMMON_CODEC_TESTS + (
20 (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
21 )
22
23class Test_ISO2022_JP2(test_multibytecodec_support.TestBase, unittest.TestCase):
24 encoding = 'iso2022_jp_2'
25 tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
26 codectests = COMMON_CODEC_TESTS + (
27 (b'ab\x1BNdef', 'replace', 'abdef'),
28 )
29
30class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
31 encoding = 'iso2022_kr'
32 tstring = test_multibytecodec_support.load_teststring('iso2022_kr')
33 codectests = COMMON_CODEC_TESTS + (
34 (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
35 )
36
37 # iso2022_kr.txt cannot be used to test "chunk coding": the escape
38 # sequence is only written on the first line
39 def test_chunkcoding(self):
40 pass
41
42def test_main():
43 support.run_unittest(__name__)
44
45if __name__ == "__main__":
46 test_main()