MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_encoding_cyrillic_unicode

Method test_encoding_cyrillic_unicode

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

Source from the content-addressed store, hash-verified

2288 os.remove(fn)
2289
2290 def test_encoding_cyrillic_unicode(self):
2291 log = logging.getLogger("test")
2292 # Get a message in Unicode: Do svidanya in Cyrillic (meaning goodbye)
2293 message = '\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'
2294 # Ensure it's written in a Cyrillic encoding
2295 writer_class = codecs.getwriter('cp1251')
2296 writer_class.encoding = 'cp1251'
2297 stream = io.BytesIO()
2298 writer = writer_class(stream, 'strict')
2299 handler = logging.StreamHandler(writer)
2300 log.addHandler(handler)
2301 try:
2302 log.warning(message)
2303 finally:
2304 log.removeHandler(handler)
2305 handler.close()
2306 # check we wrote exactly those bytes, ignoring trailing \n etc
2307 s = stream.getvalue()
2308 # Compare against what the data should be when encoded in CP-1251
2309 self.assertEqual(s, b'\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
2310
2311
2312class 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