'If L{LengthEnforcingConsumer.write} calls the producer\'s
C{stopProducing} because too many bytes were written and the
C{stopProducing} method raises an exception, the exception is logged
and the L{LengthEnforcingConsumer} still errbacks the finished
L{Deferred}.'

def test_stopProducingRaises(self):

    def brokenStopProducing():
        StringProducer.stopProducing(self.producer)
        raise ArbitraryException(u'stopProducing    is    busted')
    self.producer.stopProducing = brokenStopProducing
    def cbFinished(ignored):
        self.assertEqual(len(self.flushLoggedErrors(ArbitraryException)), 1)
    d = self.test_writeTooMany()
    d.addCallback(cbFinished)
    return d
