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

Method test_errorhandle

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

Source from the content-addressed store, hash-verified

368 self.assertEqual(str(csetch, self.encoding), unich)
369
370 def test_errorhandle(self):
371 for source, scheme, expected in self.codectests:
372 if isinstance(source, bytes):
373 func = source.decode
374 else:
375 func = source.encode
376 if expected:
377 if isinstance(source, bytes):
378 result = func(self.encoding, scheme)
379 self.assertTrue(type(result) is str, type(result))
380 self.assertEqual(result, expected,
381 '%a.decode(%r, %r)=%a != %a'
382 % (source, self.encoding, scheme, result,
383 expected))
384 else:
385 result = func(self.encoding, scheme)
386 self.assertTrue(type(result) is bytes, type(result))
387 self.assertEqual(result, expected,
388 '%a.encode(%r, %r)=%a != %a'
389 % (source, self.encoding, scheme, result,
390 expected))
391 else:
392 self.assertRaises(UnicodeError, func, self.encoding, scheme)
393
394def load_teststring(name):
395 dir = os.path.join(os.path.dirname(__file__), 'cjkencodings')

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