MCPcopy Index your code
hub / github.com/python/cpython / test_fake_error_class

Method test_fake_error_class

Lib/test/test_codeccallbacks.py:1250–1272  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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 [

Callers

nothing calls this directly

Calls 4

FakeUnicodeErrorClass · 0.85
handlerFunction · 0.85
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected