Skip to content

Commit a2816c2

Browse files
committed
more test to more general test file, so it can test more things
1 parent 2f560fa commit a2816c2

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/test/multibytecodec_support.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ def xmlcharnamereplace(exc):
108108
self.assertEqual(self.encode(sin,
109109
"test.xmlcharnamereplace")[0], sout)
110110

111+
def test_callback_returns_bytes(self):
112+
def myreplace(exc):
113+
return (b"1234", exc.end)
114+
codecs.register_error("test.cjktest", myreplace)
115+
enc = self.encode("abc" + self.unmappedunicode + "def", "test.cjktest")[0]
116+
self.assertEqual(enc, b"abc1234def")
117+
111118
def test_callback_wrong_objects(self):
112119
def myreplace(exc):
113120
return (ret, exc.end)

Lib/test/test_multibytecodec.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ def test_errorcallback_longindex(self):
4545
self.assertRaises(IndexError, dec,
4646
b'apple\x92ham\x93spam', 'test.cjktest')
4747

48-
def test_errorhandler_returns_bytes(self):
49-
enc = "\u30fb\udc80".encode('gb18030', 'surrogateescape')
50-
self.assertEqual(enc, b'\x819\xa79\x80')
51-
5248
def test_codingspec(self):
5349
try:
5450
for enc in ALL_CJKENCODINGS:

0 commit comments

Comments
 (0)