def test_connectionFailed(self):
        request = DummyRequest([b'foo'])
        factory = ProxyClientFactory(b'GET', b'/foo', b'HTTP/1.0',
                                     {b"accept": b"text/html"}, '', request)

        factory.clientConnectionFailed(None, None)
        self.assertEqual(request.responseCode, 501)
        self.assertEqual(request.responseMessage, b"Gateway error")
        self.assertEqual(
            list(request.responseHeaders.getAllRawHeaders()),
            [(b"Content-Type", [b"text/html"])])
        self.assertEqual(
            b''.join(request.written),
            b"<H1>Could not connect</H1>")
        self.assertEqual(request.finished, 1)
Test the concept of a nullable type
dataset/ETHPy150Open twisted/twisted/twisted/web/test/test_proxy.py/ProxyClientFactoryTests.test_connectionFailed--crossover with--dataset/ETHPy150Open timothycrosley/hug/tests/test_types.py/test_nullable