def test_connectionLost(self):
        """
        If there is an error issuing the request to the remote publisher, an
        error response is returned.
        """
        # Using pb.Root as a publisher will cause request calls to fail with an
        # error every time.  Just what we want to test.
        self.f1 = serverFactory = PBServerFactory(pb.Root())
        self.port1 = serverPort = reactor.listenTCP(0, serverFactory)

        self.sub = subscription = distrib.ResourceSubscription(
            "127.0.0.1", serverPort.getHost().port)
        request = DummyRequest([b''])
        d = _render(subscription, request)
        def cbRendered(ignored):
            self.assertEqual(request.responseCode, 500)
            # This is the error we caused the request to fail with.  It should
            # have been logged.
            errors = self.flushLoggedErrors(pb.NoSuchMethod)
            self.assertEqual(len(errors), 1)
            # The error page is rendered as HTML.
            expected = [
                b'',
                b'<html>',
                b'  <head><title>500 - Server Connection Lost</title></head>',
                b'  <body>',
                b'    <h1>Server Connection Lost</h1>',
                b'    <p>Connection to distributed server lost:'
                    b'<pre>'
                    b'[Failure instance: Traceback from remote host -- '
                b'twisted.spread.flavors.NoSuchMethod: '
                    b'No such method: remote_request',
                b']</pre></p>',
                b'  </body>',
                b'</html>',
                b''
                ]
            self.assertEqual([b'\n'.join(expected)], request.written)

        d.addCallback(cbRendered)
        return d

        If there is an error issuing the request to the remote publisher, an
        error response is returned.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_distrib.py