'If the L{Deferred} returned by L{Request.writeTo} fires with a
L{Failure}, L{HTTP11ClientProtocol.request} disconnects its transport
and returns a L{Deferred} which fires with a L{Failure} of
L{RequestGenerationFailed} wrapping the underlying failure.'

def test_failedWriteTo(self):

    class BrokenRequest:
        persistent = False
        def writeTo(self, transport):
            return fail(ArbitraryException())
    d = self.protocol.request(BrokenRequest())
    def cbFailed(ignored):
        self.assertTrue(self.transport.disconnecting)
        self.protocol.connectionLost(Failure(ConnectionDone(u'you    asked    for    it')))
    d = assertRequestGenerationFailed(self, d, [ArbitraryException])
    d.addCallback(cbFailed)
    return d
