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