

def test_error_message(self):
    retry = Retry(total=0)
    try:
        retry = retry.increment(error=ReadTimeoutError(None, '/', 'read timed out'))
        raise AssertionError('Should have raised a MaxRetryError')
    except MaxRetryError as e:
        assert ('Caused by redirect' not in str(e))
        self.assertEqual(str(self.reason), 'None: read timed out')
    retry = Retry(total=1)
    try:
        retry = retry.increment('POST', '/')
        retry = retry.increment('POST', '/')
        raise AssertionError('Should have raised a MaxRetryError')
    except MaxRetryError as e:
        assert ('Caused by redirect' not in str(e))
        self.assertTrue(isinstance(e.reason, ResponseError), ('%s should be a ResponseError' % e.reason))
        self.assertEqual(str(e.reason), ResponseError.GENERIC_ERROR)
    retry = Retry(total=1)
    try:
        response = HTTPResponse(status=500)
        retry = retry.increment('POST', '/', response=response)
        retry = retry.increment('POST', '/', response=response)
        raise AssertionError('Should have raised a MaxRetryError')
    except MaxRetryError as e:
        assert ('Caused by redirect' not in str(e))
        msg = ResponseError.SPECIFIC_ERROR.format(status_code=500)
        self.assertEqual(str(e.reason), msg)
    retry = Retry(connect=1)
    try:
        retry = retry.increment(error=ConnectTimeoutError('conntimeout'))
        retry = retry.increment(error=ConnectTimeoutError('conntimeout'))
        raise AssertionError('Should have raised a MaxRetryError')
    except MaxRetryError as e:
        assert ('Caused by redirect' not in str(e))
        self.assertEqual(str(e.reason), 'conntimeout')

dataset/ETHPy150Open shazow/urllib3/test/test_retry.py RetryTest.test_error_message/VarMisuse@72/109 `e`->`self`