'startLogging() installs FileLogObserver and overrides sys.stdout and
sys.stderr.'

def test_startLogging(self):

    (origStdout, origStderr) = (sys.stdout, sys.stderr)
    self._startLoggingCleanup()
    fakeFile = StringIO()
    observer = log.startLogging(fakeFile)
    self.addCleanup(observer.stop)
    log.msg('Hello!')
    self.assertIn('Hello!', fakeFile.getvalue())
    self.assertIsInstance(sys.stdout, LoggingFile)
    self.assertEqual(sys.stdout.level, NewLogLevel.info)
    encoding = getattr(origStdout, 'encoding', None)
    if (not encoding):
        encoding = sys.getdefaultencoding()
    self.assertEqual(sys.stdout.encoding.upper(), encoding.upper())
    self.assertIsInstance(sys.stderr, LoggingFile)
    self.assertEqual(sys.stderr.level, NewLogLevel.error)
    encoding = getattr(origStderr, 'encoding', None)
    if (not encoding):
        encoding = sys.getdefaultencoding()
    self.assertEqual(sys.stderr.encoding.upper(), encoding.upper())
