summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-12-02 13:04:37 -0500
committerBenjamin Peterson <benjamin@python.org>2012-12-02 13:04:37 -0500
commit540a1f12c93bd58e8a22287bd24fb42280bcdb05 (patch)
tree2d1204fc97636fd074e34304888c7b5c8626f482
parent8add8bb70f4f46ded51a2a090504bebfdce62913 (diff)
downloadcpython-540a1f12c93bd58e8a22287bd24fb42280bcdb05.tar.gz
more test to more general test file, so it can test more things
-rw-r--r--Lib/test/multibytecodec_support.py7
-rw-r--r--Lib/test/test_multibytecodec.py4
2 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/multibytecodec_support.py b/Lib/test/multibytecodec_support.py
index 5f08f10606..26bac7be10 100644
--- a/Lib/test/multibytecodec_support.py
+++ b/Lib/test/multibytecodec_support.py
@@ -108,6 +108,13 @@ class TestBase:
self.assertEqual(self.encode(sin,
"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 myreplace(exc):
return (ret, exc.end)
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 7b47cb50e8..feb7bd595a 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -45,10 +45,6 @@ class Test_MultibyteCodec(unittest.TestCase):
self.assertRaises(IndexError, dec,
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):
try:
for enc in ALL_CJKENCODINGS: