summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecencodings_iso2022.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-30 22:03:07 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-30 22:03:07 (GMT)
commit1eb6d278a8139dda25efbe1b3509aac159bc54fd (patch)
treef53f7094328a3e7693c3fb3c275e76956b9dedb0 /Lib/test/test_codecencodings_iso2022.py
parent4f1252dfbe4d7ad9f65568e0fb37d12c2ad766dc (diff)
parentee49797c8dacb886d58804e59f6431ea6f842be2 (diff)
downloadcpython-1eb6d278a8139dda25efbe1b3509aac159bc54fd.zip
cpython-1eb6d278a8139dda25efbe1b3509aac159bc54fd.tar.gz
cpython-1eb6d278a8139dda25efbe1b3509aac159bc54fd.tar.bz2
(Merge 3.2) Issue #12057: Add tests for ISO 2022 codecs
iso2022_jp, iso2022_jp_2 and iso2022_kr
Diffstat (limited to 'Lib/test/test_codecencodings_iso2022.py')
-rw-r--r--Lib/test/test_codecencodings_iso2022.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/test/test_codecencodings_iso2022.py b/Lib/test/test_codecencodings_iso2022.py
new file mode 100644
index 0000000..8c6e8a5
--- /dev/null
+++ b/Lib/test/test_codecencodings_iso2022.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Codec encoding tests for ISO 2022 encodings.
+
+from test import support
+from test import test_multibytecodec_support
+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'),
+ )
+
+class Test_ISO2022_JP(test_multibytecodec_support.TestBase, unittest.TestCase):
+ encoding = 'iso2022_jp'
+ tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
+ codectests = COMMON_CODEC_TESTS + (
+ (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
+ )
+
+class Test_ISO2022_JP2(test_multibytecodec_support.TestBase, unittest.TestCase):
+ encoding = 'iso2022_jp_2'
+ tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
+ codectests = COMMON_CODEC_TESTS + (
+ (b'ab\x1BNdef', 'replace', 'abdef'),
+ )
+
+class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
+ encoding = 'iso2022_kr'
+ tstring = test_multibytecodec_support.load_teststring('iso2022_kr')
+ 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
+ def test_chunkcoding(self):
+ pass
+
+def test_main():
+ support.run_unittest(__name__)
+
+if __name__ == "__main__":
+ test_main()