@@ -50,6 +50,35 @@ class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase):
5050 )
5151 has_iso10646 = True
5252
53+ class Test_HZ (test_multibytecodec_support .TestBase , unittest .TestCase ):
54+ encoding = 'hz'
55+ tstring = test_multibytecodec_support .load_teststring ('hz' )
56+ codectests = (
57+ # test '~\n' (3 lines)
58+ (b'This sentence is in ASCII.\n '
59+ b'The next sentence is in GB.~{<:Ky2;S{#,~}~\n '
60+ b'~{NpJ)l6HK!#~}Bye.\n ' ,
61+ 'strict' ,
62+ 'This sentence is in ASCII.\n '
63+ 'The next sentence is in GB.'
64+ '\u5df1 \u6240 \u4e0d \u6b32 \uff0c \u52ff \u65bd \u65bc \u4eba \u3002 '
65+ 'Bye.\n ' ),
66+ # test '~\n' (4 lines)
67+ (b'This sentence is in ASCII.\n '
68+ b'The next sentence is in GB.~\n '
69+ b'~{<:Ky2;S{#,NpJ)l6HK!#~}~\n '
70+ b'Bye.\n ' ,
71+ 'strict' ,
72+ 'This sentence is in ASCII.\n '
73+ 'The next sentence is in GB.'
74+ '\u5df1 \u6240 \u4e0d \u6b32 \uff0c \u52ff \u65bd \u65bc \u4eba \u3002 '
75+ 'Bye.\n ' ),
76+ # invalid bytes
77+ (b'ab~cd' , 'replace' , 'ab\uFFFD d' ),
78+ (b'ab\xff cd' , 'replace' , 'ab\uFFFD cd' ),
79+ (b'ab~{\x81 \x81 \x41 \x44 ~}cd' , 'replace' , 'ab\uFFFD \uFFFD \u804A cd' ),
80+ )
81+
5382def test_main ():
5483 support .run_unittest (__name__ )
5584
0 commit comments