'If the L{Deferred} returned from the C{startProducing} method of the
L{IBodyProducer} passed to L{Request} fires with a L{Failure}, the
L{Deferred} returned from L{Request.writeTo} fails with that
L{Failure}.'

def test_sendRequestBodyWithError(self):

    producer = StringProducer(5)
    request = Request('POST', '/bar', _boringHeaders, producer)
    writeDeferred = request.writeTo(self.transport)
    self.assertIdentical(self.transport.producer, producer)
    self.assertTrue(self.transport.streaming)
    producer.consumer.write('ab')
    self.assertEqual(self.transport.value(), 'POST    /bar    HTTP/1.1\r\nConnection:    close\r\nContent-Length:    5\r\nHost:    example.com\r\n\r\nab')
    self.assertFalse(self.transport.disconnecting)
    producer.finished.errback(Failure(ArbitraryException()))
    self.assertFalse(self.transport.disconnecting)
    self.assertIdentical(self.transport.producer, None)
    return self.assertFailure(writeDeferred, ArbitraryException)
