ยปCore Development>Code coverage>Lib/test/test_codecencodings_kr.py

Python code coverage for Lib/test/test_codecencodings_kr.py

#countcontent
1n/a#
2n/a# test_codecencodings_kr.py
3n/a# Codec encoding tests for ROK encodings.
4n/a#
5n/a
6n/afrom test import multibytecodec_support
7n/aimport unittest
8n/a
9n/aclass Test_CP949(multibytecodec_support.TestBase, unittest.TestCase):
10n/a encoding = 'cp949'
11n/a tstring = multibytecodec_support.load_teststring('cp949')
12n/a codectests = (
13n/a # invalid bytes
14n/a (b"abc\x80\x80\xc1\xc4", "strict", None),
15n/a (b"abc\xc8", "strict", None),
16n/a (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\uc894"),
17n/a (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\uc894\ufffd"),
18n/a (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"),
19n/a )
20n/a
21n/aclass Test_EUCKR(multibytecodec_support.TestBase, unittest.TestCase):
22n/a encoding = 'euc_kr'
23n/a tstring = multibytecodec_support.load_teststring('euc_kr')
24n/a codectests = (
25n/a # invalid bytes
26n/a (b"abc\x80\x80\xc1\xc4", "strict", None),
27n/a (b"abc\xc8", "strict", None),
28n/a (b"abc\x80\x80\xc1\xc4", "replace", 'abc\ufffd\ufffd\uc894'),
29n/a (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\uc894\ufffd"),
30n/a (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"),
31n/a
32n/a # composed make-up sequence errors
33n/a (b"\xa4\xd4", "strict", None),
34n/a (b"\xa4\xd4\xa4", "strict", None),
35n/a (b"\xa4\xd4\xa4\xb6", "strict", None),
36n/a (b"\xa4\xd4\xa4\xb6\xa4", "strict", None),
37n/a (b"\xa4\xd4\xa4\xb6\xa4\xd0", "strict", None),
38n/a (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4", "strict", None),
39n/a (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "strict", "\uc4d4"),
40n/a (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4x", "strict", "\uc4d4x"),
41n/a (b"a\xa4\xd4\xa4\xb6\xa4", "replace", 'a\ufffd'),
42n/a (b"\xa4\xd4\xa3\xb6\xa4\xd0\xa4\xd4", "strict", None),
43n/a (b"\xa4\xd4\xa4\xb6\xa3\xd0\xa4\xd4", "strict", None),
44n/a (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa3\xd4", "strict", None),
45n/a (b"\xa4\xd4\xa4\xff\xa4\xd0\xa4\xd4", "replace", '\ufffd\u6e21\ufffd\u3160\ufffd'),
46n/a (b"\xa4\xd4\xa4\xb6\xa4\xff\xa4\xd4", "replace", '\ufffd\u6e21\ub544\ufffd\ufffd'),
47n/a (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xff", "replace", '\ufffd\u6e21\ub544\u572d\ufffd'),
48n/a (b"\xa4\xd4\xff\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "replace", '\ufffd\ufffd\ufffd\uc4d4'),
49n/a (b"\xc1\xc4", "strict", "\uc894"),
50n/a )
51n/a
52n/aclass Test_JOHAB(multibytecodec_support.TestBase, unittest.TestCase):
53n/a encoding = 'johab'
54n/a tstring = multibytecodec_support.load_teststring('johab')
55n/a codectests = (
56n/a # invalid bytes
57n/a (b"abc\x80\x80\xc1\xc4", "strict", None),
58n/a (b"abc\xc8", "strict", None),
59n/a (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\ucd27"),
60n/a (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\ucd27\ufffd"),
61n/a (b"abc\x80\x80\xc1\xc4", "ignore", "abc\ucd27"),
62n/a (b"\xD8abc", "replace", "\uFFFDabc"),
63n/a (b"\xD8\xFFabc", "replace", "\uFFFD\uFFFDabc"),
64n/a (b"\x84bxy", "replace", "\uFFFDbxy"),
65n/a (b"\x8CBxy", "replace", "\uFFFDBxy"),
66n/a )
67n/a
68n/aif __name__ == "__main__":
69n/a unittest.main()