def test_socks4aFailedResolution(self):
        """
        Failed hostname resolution on a SOCKSv4a packet results in a 91 error
        response and the connection getting closed.
        """
        # send the domain name "failinghost" to be resolved
        clientRequest = (
            struct.pack('!BBH', 4, 2, 34)
            + socket.inet_aton('0.0.0.1')
            + b'fooBAZ\0'
            + b'failinghost\0')

        # Deliver the bytes one by one to exercise the protocol's buffering
        # logic. FakeResolverReactor's resolve method is invoked to "resolve"
        # the hostname.
        for byte in iterbytes(clientRequest):
            self.sock.dataReceived(byte)

        # Verify that the server responds with a 91 error.
        sent = self.sock.transport.value()
        self.assertEqual(
            sent,
            struct.pack('!BBH', 0, 91, 0) + socket.inet_aton('0.0.0.0'))

        # A failed resolution causes the transport to drop the connection.
        self.assertTrue(self.sock.transport.stringTCPTransport_closing)
        self.assertIsNone(self.sock.driver_outgoing)

        Failed hostname resolution on a SOCKSv4a packet results in a 91 error
        response and the connection getting closed.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_socks.py