Mailing List Archive

python/dist/src/Lib/test test_codeccallbacks.py,1.1,1.2
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv7207

Modified Files:
test_codeccallbacks.py
Log Message:
Add a test case that checks that the proper exception is raises
when the replacement from an encoding error callback is itself
unencodable.


Index: test_codeccallbacks.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codeccallbacks.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_codeccallbacks.py 2 Sep 2002 13:14:30 -0000 1.1
--- test_codeccallbacks.py 6 Sep 2002 17:21:40 -0000 1.2
***************
*** 475,478 ****
--- 475,493 ----
)

+ def test_unencodablereplacement(self):
+ def unencrepl(exc):
+ if isinstance(exc, UnicodeEncodeError):
+ return (u"\u4242", exc.end)
+ else:
+ raise TypeError("don't know how to handle %r" % exc)
+ codecs.register_error("test.unencreplhandler", unencrepl)
+ for enc in ("ascii", "iso-8859-1", "iso-8859-15"):
+ self.assertRaises(
+ UnicodeEncodeError,
+ u"\u4242".encode,
+ enc,
+ "test.unencreplhandler"
+ )
+
def test_main():
suite = unittest.TestSuite()