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

Method test_codecs_lookup

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

Source from the content-addressed store, hash-verified

3874class CodecNameNormalizationTest(unittest.TestCase):
3875 """Test codec name normalization"""
3876 def test_codecs_lookup(self):
3877 def search_function(encoding):
3878 if encoding.startswith("test."):
3879 return (encoding, 2, 3, 4)
3880 else:
3881 return None
3882
3883 codecs.register(search_function)
3884 self.addCleanup(codecs.unregister, search_function)
3885 self.assertEqual(codecs.lookup('test.aaa_8'), ('test.aaa_8', 2, 3, 4))
3886 self.assertEqual(codecs.lookup('TEST.AAA-8'), ('test.aaa-8', 2, 3, 4))
3887 self.assertEqual(codecs.lookup('TEST.AAA 8'), ('test.aaa-8', 2, 3, 4))
3888 self.assertEqual(codecs.lookup('TEST.AAA---8'), ('test.aaa---8', 2, 3, 4))
3889 self.assertEqual(codecs.lookup('TEST.AAA 8'), ('test.aaa---8', 2, 3, 4))
3890 self.assertEqual(codecs.lookup('TEST.AAA.8'), ('test.aaa.8', 2, 3, 4))
3891 self.assertEqual(codecs.lookup('TEST.AAA...8'), ('test.aaa...8', 2, 3, 4))
3892 with self.assertWarns(DeprecationWarning):
3893 self.assertEqual(codecs.lookup('TEST.AAA\xe9\u20ac-8'), ('test.aaa\xe9\u20ac-8', 2, 3, 4))
3894
3895 def test_encodings_normalize_encoding(self):
3896 normalize = encodings.normalize_encoding

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
assertWarnsMethod · 0.80
registerMethod · 0.45
assertEqualMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected