'L{renderElement} handles failures by writing a minimal
error message to the request and finishing it.'

def test_simpleFailure(self):

    element = FailingElement()
    d = self.request.notifyFinish()
    def check(_):
        flushed = self.flushLoggedErrors(FlattenerError)
        self.assertEqual(len(flushed), 1)
        self.assertEqual(''.join(self.request.written), '<!DOCTYPE    html>\n<div    style="font-size:800%;background-color:#FFF;color:#F00">An    error    occurred    while    rendering    the    response.</div>')
        self.assertTrue(self.request.finished)
    d.addCallback(check)
    self.assertIdentical(NOT_DONE_YET, renderElement(self.request, element))
    return d
