def test_unregistersProducer(self):
        """
        The L{_GenericHTTPChannelProtocol} will unregister its proxy channel
        from the transport if upgrade is negotiated.
        """
        transport = StringTransport()
        transport.negotiatedProtocol = b'h2'

        genericProtocol = http._genericHTTPChannelProtocolFactory(b'')
        genericProtocol.requestFactory = DummyHTTPHandlerProxy
        genericProtocol.makeConnection(transport)

        # We expect the transport has a underlying channel registered as
        # a producer.
        self.assertIs(transport.producer, genericProtocol._channel)

        # Force the upgrade.
        genericProtocol.dataReceived(b'P')

        # The transport should now have no producer.
        self.assertIs(transport.producer, None)

        The L{_GenericHTTPChannelProtocol} will unregister its proxy channel
        from the transport if upgrade is negotiated.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py