(self)
| 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 | |
| 2338 | class WarningsTest(BaseTest): |
nothing calls this directly
no test coverage detected