'When the streaming producer is stopped by the consumer, the underlying
producer is stopped, and streaming is stopped.'

def test_stopProducing(self):

    class StoppingStringTransport(StringTransport, ):
        writes = 0
        def write(self, data):
            self.writes += 1
            StringTransport.write(self, data)
            if (self.writes == 3):
                self.producer.stopProducing()
    consumer = StoppingStringTransport()
    nsProducer = NonStreamingProducer(consumer)
    streamingProducer = _PullToPush(nsProducer, consumer)
    consumer.registerProducer(streamingProducer, True)
    done = nsProducer.result
    def doneStreaming(_):
        self.assertEqual(consumer.value(), '012')
        self.assertTrue(nsProducer.stopped)
        self.assertTrue(streamingProducer._finished)
    done.addCallback(doneStreaming)
    streamingProducer.startStreaming()
    return done
