'Verify the consumer writes out all its data, but is not called after
that.'

def streamUntilEnd(self, consumer):

    nsProducer = NonStreamingProducer(consumer)
    streamingProducer = _PullToPush(nsProducer, consumer)
    consumer.registerProducer(streamingProducer, True)
    def unregister(orig=consumer.unregisterProducer):
        orig()
        streamingProducer.stopStreaming()
    consumer.unregisterProducer = unregister
    done = nsProducer.result
    def doneStreaming(_):
        self.assertEqual(consumer.value(), '0123456789')
        self.assertIsNone(consumer.producer)
        self.assertTrue(streamingProducer._finished)
    done.addCallback(doneStreaming)
    streamingProducer.startStreaming()
    return done
