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