def test_producerDuringRenegotiation(self):
        """
        If we write some data to a TLS connection that is blocked waiting for a
        renegotiation with its peer, it will pause and resume its registered
        producer exactly once.
        """
        c, ct, cp = self.setupStreamingProducer()
        s, st, sp = self.setupStreamingProducer(server=True)

        self.flushTwoTLSProtocols(ct, st)
        # no public API for this yet because it's (mostly) unnecessary, but we
        # have to be prepared for a peer to do it to us
        tlsc = ct._tlsConnection
        tlsc.renegotiate()
        self.assertRaises(WantReadError, tlsc.do_handshake)
        ct._flushSendBIO()
        st.dataReceived(self.drain(ct.transport))
        payload = b'payload'
        s.transport.write(payload)
        s.transport.loseConnection()
        # give the client the server the client's response...
        ct.dataReceived(self.drain(st.transport))
        messageThatUnblocksTheServer = self.drain(ct.transport)
        # split it into just enough chunks that it would provoke the producer
        # with an incorrect implementation...
        for fragment in (messageThatUnblocksTheServer[0:1],
                         messageThatUnblocksTheServer[1:2],
                         messageThatUnblocksTheServer[2:]):
            st.dataReceived(fragment)
        self.assertEqual(st.transport.disconnecting, False)
        s.transport.unregisterProducer()
        self.flushTwoTLSProtocols(ct, st)
        self.assertEqual(st.transport.disconnecting, True)
        self.assertEqual(b''.join(c.received), payload)
        self.assertEqual(sp.producerHistory, ['pause', 'resume'])

        If we write some data to a TLS connection that is blocked waiting for a
        renegotiation with its peer, it will pause and resume its registered
        producer exactly once.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/protocols/test/test_tls.py