def METHOD_NAME():
    stream = MagicMock(encoding='ascii')
    stream.write.side_effect = [UnicodeEncodeError('ascii', 'zzz', 0, 1, 'error message'), None]
    wrapper = StreamWrapper(stream)
    wrapper.write('hello привет')
    stream.write.assert_has_calls([call('hello привет'), call('hello \\u043f\\u0440\\u0438\\u0432\\u0435\\u0442')])
    byte_stream = BytesIO()
    stream = TextIOWrapper(byte_stream, encoding='ascii')
    wrapper = StreamWrapper(stream)
    wrapper.write("hello привет")
    wrapper.flush()
    assert byte_stream.getvalue() == b'hello \\u043f\\u0440\\u0438\\u0432\\u0435\\u0442'