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

Method check_encode_strings

Lib/test/test_codecs.py:3738–3750  ·  view source on GitHub ↗
(self, errors)

Source from the content-addressed store, hash-verified

3736 return _testinternalcapi.EncodeLocaleEx(text, 0, errors)
3737
3738 def check_encode_strings(self, errors):
3739 for text in self.STRINGS:
3740 with self.subTest(text=text):
3741 try:
3742 expected = text.encode(self.ENCODING, errors)
3743 except UnicodeEncodeError:
3744 with self.assertRaises(RuntimeError) as cm:
3745 self.encode(text, errors)
3746 errmsg = str(cm.exception)
3747 self.assertRegex(errmsg, r"encode error: pos=[0-9]+, reason=")
3748 else:
3749 encoded = self.encode(text, errors)
3750 self.assertEqual(encoded, expected)
3751
3752 def test_encode_strict(self):
3753 self.check_encode_strings("strict")

Callers 3

test_encode_strictMethod · 0.95

Calls 6

encodeMethod · 0.95
strFunction · 0.85
assertRegexMethod · 0.80
subTestMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected