mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
more test to more general test file, so it can test more things
This commit is contained in:
parent
2f560fa300
commit
a2816c2b11
2 changed files with 7 additions and 4 deletions
|
@ -108,6 +108,13 @@ class TestBase:
|
||||||
self.assertEqual(self.encode(sin,
|
self.assertEqual(self.encode(sin,
|
||||||
"test.xmlcharnamereplace")[0], sout)
|
"test.xmlcharnamereplace")[0], sout)
|
||||||
|
|
||||||
|
def test_callback_returns_bytes(self):
|
||||||
|
def myreplace(exc):
|
||||||
|
return (b"1234", exc.end)
|
||||||
|
codecs.register_error("test.cjktest", myreplace)
|
||||||
|
enc = self.encode("abc" + self.unmappedunicode + "def", "test.cjktest")[0]
|
||||||
|
self.assertEqual(enc, b"abc1234def")
|
||||||
|
|
||||||
def test_callback_wrong_objects(self):
|
def test_callback_wrong_objects(self):
|
||||||
def myreplace(exc):
|
def myreplace(exc):
|
||||||
return (ret, exc.end)
|
return (ret, exc.end)
|
||||||
|
|
|
@ -45,10 +45,6 @@ class Test_MultibyteCodec(unittest.TestCase):
|
||||||
self.assertRaises(IndexError, dec,
|
self.assertRaises(IndexError, dec,
|
||||||
b'apple\x92ham\x93spam', 'test.cjktest')
|
b'apple\x92ham\x93spam', 'test.cjktest')
|
||||||
|
|
||||||
def test_errorhandler_returns_bytes(self):
|
|
||||||
enc = "\u30fb\udc80".encode('gb18030', 'surrogateescape')
|
|
||||||
self.assertEqual(enc, b'\x819\xa79\x80')
|
|
||||||
|
|
||||||
def test_codingspec(self):
|
def test_codingspec(self):
|
||||||
try:
|
try:
|
||||||
for enc in ALL_CJKENCODINGS:
|
for enc in ALL_CJKENCODINGS:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue