'L{Runner.startLogging} sets up a filtering observer with a log level
predicate set to the given log level that contains a file observer of
the given type which writes to the given file.'

def test_startLogging(self):

    logFile = BytesIO()
    class LogBeginner(object, ):
        def beginLoggingTo(self, observers):
            LogBeginner.observers = observers
    self.patch(_runner, 'globalLogBeginner', LogBeginner())
    class MockFilteringLogObserver(FilteringLogObserver, ):
        def __init__(self, observer, predicates, negativeObserver=(lambda event: None)):
            MockFilteringLogObserver.observer = observer
            MockFilteringLogObserver.predicates = predicates
            FilteringLogObserver.__init__(self, observer, predicates, negativeObserver)
    self.patch(_runner, 'FilteringLogObserver', MockFilteringLogObserver)
    class MockFileLogObserver(FileLogObserver, ):
        def __init__(self, outFile):
            MockFileLogObserver.outFile = outFile
            FileLogObserver.__init__(self, outFile, str)
    runner = Runner(reactor=MemoryReactor(), defaultLogLevel=LogLevel.critical, logFile=logFile, fileLogObserverFactory=MockFileLogObserver)
    runner.startLogging()
    self.assertEqual(len(LogBeginner.observers), 1)
    self.assertIsInstance(LogBeginner.observers[0], FilteringLogObserver)
    self.assertEqual(len(MockFilteringLogObserver.predicates), 1)
    self.assertIsInstance(MockFilteringLogObserver.predicates[0], LogLevelFilterPredicate)
    self.assertIdentical(MockFilteringLogObserver.predicates[0].defaultLogLevel, LogLevel.critical)
    self.assertIsInstance(MockFilteringLogObserver.observer, MockFileLogObserver)
    self.assertIdentical(MockFilteringLogObserver.observer.outFile, logFile)
