(self)
| 1248 | ) |
| 1249 | |
| 1250 | def test_fake_error_class(self): |
| 1251 | handlers = [ |
| 1252 | codecs.strict_errors, |
| 1253 | codecs.ignore_errors, |
| 1254 | codecs.replace_errors, |
| 1255 | codecs.backslashreplace_errors, |
| 1256 | codecs.namereplace_errors, |
| 1257 | codecs.xmlcharrefreplace_errors, |
| 1258 | codecs.lookup_error('surrogateescape'), |
| 1259 | codecs.lookup_error('surrogatepass'), |
| 1260 | ] |
| 1261 | for cls in UnicodeEncodeError, UnicodeDecodeError, UnicodeTranslateError: |
| 1262 | class FakeUnicodeError(str): |
| 1263 | __class__ = cls |
| 1264 | for handler in handlers: |
| 1265 | with self.subTest(handler=handler, error_class=cls): |
| 1266 | self.assertRaises(TypeError, handler, FakeUnicodeError()) |
| 1267 | class FakeUnicodeError(Exception): |
| 1268 | __class__ = cls |
| 1269 | for handler in handlers: |
| 1270 | with self.subTest(handler=handler, error_class=cls): |
| 1271 | with self.assertRaises((TypeError, FakeUnicodeError)): |
| 1272 | handler(FakeUnicodeError()) |
| 1273 | |
| 1274 | def test_reject_unregister_builtin_error_handler(self): |
| 1275 | for name in [ |
nothing calls this directly
no test coverage detected