test_codecencodings_iso2022.py 1.43 KB
Newer Older
1 2 3
# Codec encoding tests for ISO 2022 encodings.

from test import support
4
from test import multibytecodec_support
5 6 7 8 9 10 11 12 13
import unittest

COMMON_CODEC_TESTS = (
        # invalid bytes
        (b'ab\xFFcd', 'replace', 'ab\uFFFDcd'),
        (b'ab\x1Bdef', 'replace', 'ab\x1Bdef'),
        (b'ab\x1B$def', 'replace', 'ab\uFFFD'),
    )

14
class Test_ISO2022_JP(multibytecodec_support.TestBase, unittest.TestCase):
15
    encoding = 'iso2022_jp'
16
    tstring = multibytecodec_support.load_teststring('iso2022_jp')
17 18 19 20
    codectests = COMMON_CODEC_TESTS + (
        (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
    )

21
class Test_ISO2022_JP2(multibytecodec_support.TestBase, unittest.TestCase):
22
    encoding = 'iso2022_jp_2'
23
    tstring = multibytecodec_support.load_teststring('iso2022_jp')
24 25 26 27
    codectests = COMMON_CODEC_TESTS + (
        (b'ab\x1BNdef', 'replace', 'abdef'),
    )

28
class Test_ISO2022_KR(multibytecodec_support.TestBase, unittest.TestCase):
29
    encoding = 'iso2022_kr'
30
    tstring = multibytecodec_support.load_teststring('iso2022_kr')
31 32 33 34 35 36
    codectests = COMMON_CODEC_TESTS + (
        (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
    )

    # iso2022_kr.txt cannot be used to test "chunk coding": the escape
    # sequence is only written on the first line
37
    @unittest.skip('iso2022_kr.txt cannot be used to test "chunk coding"')
38 39 40 41 42 43 44 45
    def test_chunkcoding(self):
        pass

def test_main():
    support.run_unittest(__name__)

if __name__ == "__main__":
    test_main()