If the file doesn't support Unicode, the string is unicode-escaped (#7475).
()
| 55 | |
| 56 | |
| 57 | def test_terminalwriter_not_unicode() -> None: |
| 58 | """If the file doesn't support Unicode, the string is unicode-escaped (#7475).""" |
| 59 | buffer = io.BytesIO() |
| 60 | file = io.TextIOWrapper(buffer, encoding="cp1252") |
| 61 | tw = terminalwriter.TerminalWriter(file) |
| 62 | tw.write("hello 🌀 wôrld אבג", flush=True) |
| 63 | assert buffer.getvalue() == rb"hello \U0001f300 w\xf4rld \u05d0\u05d1\u05d2" |
| 64 | |
| 65 | |
| 66 | win32 = int(sys.platform == "win32") |