'When L{LogBeginner.beginLoggingTo} redirects stdout/stderr streams, the
replacement streams will preserve the encoding of the replaced streams,
to minimally disrupt any application relying on a specific encoding.'

def test_beginLoggingToPreservesEncoding(self):

    weird = io.TextIOWrapper(io.BytesIO(), 'shift-JIS')
    weirderr = io.TextIOWrapper(io.BytesIO(), 'big5')
    self.sysModule.stdout = weird
    self.sysModule.stderr = weirderr
    x = []
    self.beginner.beginLoggingTo([x.append])
    self.assertEqual(self.sysModule.stdout.encoding, 'shift-JIS')
    self.assertEqual(self.sysModule.stderr.encoding, 'big5')
    self.sysModule.stdout.write('\x97\x9b\n')
    self.sysModule.stderr.write('\xbc\xfc\n')
    compareEvents(self, x, [dict(log_io=u'\u674e'), dict(log_io=u'\u7469')])
