'Helper for testing that an exception is logged by the time the
client protocol loses its connection.'

def _notificationRaisesTest(self):

    closed = self.clientProtocol.closedDeferred = defer.Deferred()
    self.clientProtocol.transport.loseWriteConnection()
    def check(ignored):
        errors = self.flushLoggedErrors(RuntimeError)
        self.assertEqual(len(errors), 1)
    closed.addCallback(check)
    return closed
