def test_cnameChain(self):
        class DummyResolver(object):
            """
            Fake resolver which generates a CNAME chain of infinite length in
            response to MX lookups.
            """
            chainCounter = 0

            def lookupMailExchange(self, domain):
                self.chainCounter += 1
                name = 'x-%d.example.com' % (self.chainCounter,)
                return defer.succeed((
                        [RRHeader(name=domain,
                                  type=Record_CNAME.TYPE,
                                  payload=Record_CNAME(name))],
                        [], []))

        cnameLimit = 3
        self.mx.resolver = DummyResolver()
        d = self.mx.getMX("mail.example.com", cnameLimit)
        self.assertFailure(
            d, twisted.mail.relaymanager.CanonicalNameChainTooLong)
        def cbChainTooLong(error):
            self.assertEqual(error.args[0], Record_CNAME("x-%d.example.com" % (cnameLimit + 1,)))
            self.assertEqual(self.mx.resolver.chainCounter, cnameLimit + 1)
        d.addCallback(cbChainTooLong)
        return d
:rtype: dict
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/mail/test/test_mail.py/MXTestCase.test_cnameChain--crossover with--dataset/ETHPy150Open zbyte64/django-hyperadmin/hyperadmin/endpoints.py/BaseEndpoint.get_state_data