def test_disallowedRegisterProducer(self):
        """
        L{StringTransport.registerProducer} raises L{RuntimeError} if a
        producer is already registered.
        """
        producer = object()
        self.transport.registerProducer(producer, True)
        self.assertRaises(
            RuntimeError, self.transport.registerProducer, object(), False)
        self.assertIs(self.transport.producer, producer)
        self.assertTrue(self.transport.streaming)

        L{StringTransport.registerProducer} raises L{RuntimeError} if a
        producer is already registered.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_testing.py