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

Method test_incremental_encode_invalid

Lib/test/test_codecs.py:1739–1754  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1737 self.assertEqual(encoder.encode("", True), b"")
1738
1739 def test_incremental_encode_invalid(self):
1740 iterencode_testcases = [
1741 (f"foo.{'\xff'*60}", UnicodeEncodeError("idna", f"{'\xff'*60}", 0, 60, "")),
1742 ("あさ.\u034f", UnicodeEncodeError("idna", "\u034f", 0, 1, "")),
1743 ]
1744 for case, expected in iterencode_testcases:
1745 with self.subTest(case=case, expected=expected):
1746 with self.assertRaises(UnicodeEncodeError) as cm:
1747 list(codecs.iterencode(case, "idna"))
1748 exc = cm.exception
1749 self.assertEqual(exc.encoding, expected.encoding)
1750 self.assertEqual(exc.object, expected.object)
1751 self.assertEqual(exc.start, expected.start)
1752 self.assertEqual(exc.end, expected.end)
1753
1754 # codecs.getincrementalencoder.encode() does not throw an error
1755
1756 def test_errors(self):
1757 """Only supports "strict" error handler"""

Callers

nothing calls this directly

Calls 5

listClass · 0.85
iterencodeMethod · 0.80
subTestMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected