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

Method test_errorhandle

Lib/test/multibytecodec_support.py:50–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 self.assertEqual(native, self.encode(u)[0])
49
50 def test_errorhandle(self):
51 for source, scheme, expected in self.codectests:
52 if isinstance(source, bytes):
53 func = self.decode
54 else:
55 func = self.encode
56 if expected:
57 result = func(source, scheme)[0]
58 if func is self.decode:
59 self.assertTrue(type(result) is str, type(result))
60 self.assertEqual(result, expected,
61 '%a.decode(%r, %r)=%a != %a'
62 % (source, self.encoding, scheme, result,
63 expected))
64 else:
65 self.assertTrue(type(result) is bytes, type(result))
66 self.assertEqual(result, expected,
67 '%a.encode(%r, %r)=%a != %a'
68 % (source, self.encoding, scheme, result,
69 expected))
70 else:
71 self.assertRaises(UnicodeError, func, source, scheme)
72
73 def test_xmlcharrefreplace(self):
74 if self.has_iso10646:

Callers

nothing calls this directly

Calls 4

assertTrueMethod · 0.80
funcFunction · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected