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

Method test_encoding_cyrillic_unicode

Lib/test/test_logging.py:2316–2335  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2314 os.remove(fn)
2315
2316 def test_encoding_cyrillic_unicode(self):
2317 log = logging.getLogger("test")
2318 # Get a message in Unicode: Do svidanya in Cyrillic (meaning goodbye)
2319 message = '\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'
2320 # Ensure it's written in a Cyrillic encoding
2321 writer_class = codecs.getwriter('cp1251')
2322 writer_class.encoding = 'cp1251'
2323 stream = io.BytesIO()
2324 writer = writer_class(stream, 'strict')
2325 handler = logging.StreamHandler(writer)
2326 log.addHandler(handler)
2327 try:
2328 log.warning(message)
2329 finally:
2330 log.removeHandler(handler)
2331 handler.close()
2332 # check we wrote exactly those bytes, ignoring trailing \n etc
2333 s = stream.getvalue()
2334 # Compare against what the data should be when encoded in CP-1251
2335 self.assertEqual(s, b'\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
2336
2337
2338class WarningsTest(BaseTest):

Callers

nothing calls this directly

Calls 7

getvalueMethod · 0.95
getLoggerMethod · 0.80
addHandlerMethod · 0.80
removeHandlerMethod · 0.80
warningMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected