def testRetrying(self):
        class successException(Exception):
            '''This exception will be raised in place of actually calling
            the actual function'''
            pass

        self.mockMax = 0
        self.theException = None
        self.theReturn = socket.socket()

        def mockCountdown(*args, **kwargs):
            if self.mockMax <= 1:
                raise successException
            else:
                self.mockMax -= 1
            raise self.theException

        try:
            # setup
            self.openRepository()
            client = conaryclient.ConaryClient(self.cfg)
            self.mock(transport.URLOpener, 'createConnection',
                      mockCountdown)

            # test ssl errors
            self.theException = socket.sslerror(socket.SSL_ERROR_EOF,
                                                'A particular ssl error')
            self.mockMax = 2
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                if 'successException' not in e.args[0]:
                    raise

            self.mockMax = 6
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                if 'A particular ssl error' not in e.args[0]:
                    raise

            # test gai errors
            self.theException = socket.gaierror(socket.EAI_AGAIN,
                                                'A particular gai error')
            self.mockMax = 2
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                if 'successException' not in e.args[0]:
                    raise

            self.mockMax = 6
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                if 'A particular gai error' not in e.args[0]:
                    raise

            # this should fail right away
            self.theException = socket.gaierror('bogus error',
                                                'bogus gai error')
            self.mockMax = 100
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                self.assertEquals(self.mockMax, 99)

            # test bad status errors
            self.theException = httplib.BadStatusLine(
                'A particular bad status line error')
            self.mockMax = 2
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                if 'successException' not in e.args[0]:
                    raise

            self.mockMax = 6
            try:
                client.repos.c['localhost'].checkVersion()
            except errors.OpenError, e:
                if 'A particular bad status line error' not in e.args[0]:
                    raise

        finally:
            self.unmock()
            self.stopRepository(serverIdx=2)
We test that conary retries in a bunch of cases
dataset/ETHPy150Open sassoftware/conary/conary_test/repositorytest/transporttest.py/TransportTest.testRetrying