'startLogging() overrides global C{warnings.showwarning} such that
warnings go to Twisted log observers.'

def test_startLoggingOverridesWarning(self):

    self._startLoggingCleanup()
    newPublisher = NewLogPublisher()
    class SysModule(object, ):
        stdout = object()
        stderr = object()
    tempLogPublisher = LogPublisher(newPublisher, newPublisher, logBeginner=LogBeginner(newPublisher, StringIO(), SysModule, warnings))
    self.patch(log, 'theLogPublisher', tempLogPublisher)
    log._oldshowwarning = None
    fakeFile = StringIO()
    evt = {'pre-start': 'event'}
    received = []
    def preStartObserver(x):
        if ('pre-start' in x.keys()):
            received.append(x)
    newPublisher(evt)
    newPublisher.addObserver(preStartObserver)
    log.startLogging(fakeFile, setStdout=False)
    self.addCleanup(tempLogPublisher._stopLogging)
    self.assertEqual(received, [])
    warnings.warn('hello!')
    output = fakeFile.getvalue()
    self.assertIn('UserWarning:    hello!', output)
