Adding Python 3.5 capability (#531)
In Python 3.5, `http.HTTPStatus` was added, previously HTTP statuses were int. Casting `http.HTTPStatus` as int to maintain backwards maintainability.
This commit is contained in:
committed by
Jon Wayne Parrott
parent
5454867160
commit
61c61a0140
@@ -1,6 +1,12 @@
|
||||
language: python
|
||||
python: 2.7
|
||||
sudo: false
|
||||
# TODO(issue 532): Fix syntax when 3.5 is natively available upstream
|
||||
matrix:
|
||||
include:
|
||||
- python: 3.5
|
||||
env:
|
||||
- TOX_ENV=py35
|
||||
env:
|
||||
matrix:
|
||||
- TOX_ENV=py26
|
||||
|
||||
@@ -1279,18 +1279,18 @@ class BasicCredentialsTests(unittest2.TestCase):
|
||||
|
||||
def test__do_refresh_request_non_json_failure(self):
|
||||
response = httplib2.Response({
|
||||
'status': http_client.BAD_REQUEST,
|
||||
'status': int(http_client.BAD_REQUEST),
|
||||
})
|
||||
content = u'Bad request'
|
||||
error_msg = 'Invalid response %s.' % (response.status,)
|
||||
error_msg = 'Invalid response %s.' % (int(response.status),)
|
||||
self._do_refresh_request_test_helper(response, content, error_msg)
|
||||
|
||||
def test__do_refresh_request_basic_failure(self):
|
||||
response = httplib2.Response({
|
||||
'status': http_client.INTERNAL_SERVER_ERROR,
|
||||
'status': int(http_client.INTERNAL_SERVER_ERROR),
|
||||
})
|
||||
content = u'{}'
|
||||
error_msg = 'Invalid response %s.' % (response.status,)
|
||||
error_msg = 'Invalid response %s.' % (int(response.status),)
|
||||
self._do_refresh_request_test_helper(response, content, error_msg)
|
||||
|
||||
def test__do_refresh_request_failure_w_json_error(self):
|
||||
@@ -1828,21 +1828,21 @@ class OAuth2WebServerFlowTest(unittest2.TestCase):
|
||||
self.assertEqual(exc_manager.exception.args, (error_msg,))
|
||||
|
||||
def test_step1_get_device_and_user_codes_non_json_failure(self):
|
||||
status = http_client.BAD_REQUEST
|
||||
status = int(http_client.BAD_REQUEST)
|
||||
content = 'Nope not JSON.'
|
||||
error_msg = 'Invalid response %s.' % (status,)
|
||||
self._step1_get_device_and_user_codes_fail_helper(status, content,
|
||||
error_msg)
|
||||
|
||||
def test_step1_get_device_and_user_codes_basic_failure(self):
|
||||
status = http_client.INTERNAL_SERVER_ERROR
|
||||
status = int(http_client.INTERNAL_SERVER_ERROR)
|
||||
content = b'{}'
|
||||
error_msg = 'Invalid response %s.' % (status,)
|
||||
self._step1_get_device_and_user_codes_fail_helper(status, content,
|
||||
error_msg)
|
||||
|
||||
def test_step1_get_device_and_user_codes_failure_w_json_error(self):
|
||||
status = http_client.BAD_GATEWAY
|
||||
status = int(http_client.BAD_GATEWAY)
|
||||
base_error = 'ZOMG user codes failure.'
|
||||
content = json.dumps({'error': base_error})
|
||||
error_msg = 'Invalid response %s. Error: %s' % (status, base_error)
|
||||
|
||||
@@ -151,13 +151,13 @@ class OAuth2ClientFileTests(unittest2.TestCase):
|
||||
access_token = '1/3w'
|
||||
token_response = {'access_token': access_token, 'expires_in': 3600}
|
||||
http = HttpMockSequence([
|
||||
({'status': str(http_client.UNAUTHORIZED)},
|
||||
({'status': str(int(http_client.UNAUTHORIZED))},
|
||||
b'Initial token expired'),
|
||||
({'status': str(http_client.UNAUTHORIZED)},
|
||||
({'status': str(int(http_client.UNAUTHORIZED))},
|
||||
b'Store token expired'),
|
||||
({'status': str(http_client.OK)},
|
||||
({'status': str(int(http_client.OK))},
|
||||
json.dumps(token_response).encode('utf-8')),
|
||||
({'status': str(http_client.OK)},
|
||||
({'status': str(int(http_client.OK))},
|
||||
b'Valid response to original request')
|
||||
])
|
||||
|
||||
@@ -196,13 +196,13 @@ class OAuth2ClientFileTests(unittest2.TestCase):
|
||||
token_response = {'access_token': valid_access_token,
|
||||
'expires_in': 3600}
|
||||
http = HttpMockSequence([
|
||||
({'status': str(http_client.UNAUTHORIZED)},
|
||||
({'status': str(int(http_client.UNAUTHORIZED))},
|
||||
b'Initial token expired'),
|
||||
({'status': str(http_client.UNAUTHORIZED)},
|
||||
({'status': str(int(http_client.UNAUTHORIZED))},
|
||||
b'Store token expired'),
|
||||
({'status': str(http_client.OK)},
|
||||
({'status': str(int(http_client.OK))},
|
||||
json.dumps(token_response).encode('utf-8')),
|
||||
({'status': str(http_client.OK)}, 'echo_request_body')
|
||||
({'status': str(int(http_client.OK))}, 'echo_request_body')
|
||||
])
|
||||
|
||||
body = six.StringIO('streaming body')
|
||||
|
||||
Reference in New Issue
Block a user