diff --git a/tests/contrib/test_flask_util.py b/tests/contrib/test_flask_util.py index b80e08c..d542036 100644 --- a/tests/contrib/test_flask_util.py +++ b/tests/contrib/test_flask_util.py @@ -229,8 +229,8 @@ class FlaskOAuth2Tests(unittest2.TestCase): with mock.patch( 'oauth2client.transport.get_http_object') as new_http: # Set-up mock. - new_http.return_value = http = http_mock.HttpMock( - data=DEFAULT_RESP) + http = http_mock.HttpMock(data=DEFAULT_RESP) + new_http.return_value = http # Run tests. state = self._setup_callback_state(client) diff --git a/tests/contrib/test_metadata.py b/tests/contrib/test_metadata.py index a8544e3..5af4ab9 100644 --- a/tests/contrib/test_metadata.py +++ b/tests/contrib/test_metadata.py @@ -32,9 +32,9 @@ EXPECTED_KWARGS = dict(headers=_metadata.METADATA_HEADERS) def request_mock(status, content_type, content): - resp = http_mock.ResponseMock( + response = http_mock.ResponseMock( {'status': status, 'content-type': content_type}) - return mock.Mock(return_value=(resp, content.encode('utf-8'))) + return mock.Mock(return_value=(response, content.encode('utf-8'))) class TestMetadata(unittest2.TestCase): diff --git a/tests/http_mock.py b/tests/http_mock.py index 34dc5e5..70d0e97 100644 --- a/tests/http_mock.py +++ b/tests/http_mock.py @@ -15,6 +15,9 @@ """HTTP helpers mock functionality.""" +from six.moves import http_client + + class ResponseMock(dict): """Mock HTTP response""" @@ -22,7 +25,7 @@ class ResponseMock(dict): if vals is None: vals = {} self.update(vals) - self.status = int(self.get('status', 200)) + self.status = int(self.get('status', http_client.OK)) class HttpMock(object): @@ -35,7 +38,7 @@ class HttpMock(object): headers: dict, header to return with response """ if headers is None: - headers = {'status': '200'} + headers = {'status': http_client.OK} self.data = data self.response_headers = headers self.headers = None diff --git a/tests/test_client.py b/tests/test_client.py index 64a7d7b..be5994f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -908,7 +908,7 @@ class BasicCredentialsTests(unittest2.TestCase): self.assertEqual(token_response, self.credentials.token_response) def test_recursive_authorize(self): - # Tests that OAuth2Credentials doesn't intro. new method constraints. + # Tests that OAuth2Credentials doesn't introduce new method constraints. # Formerly, OAuth2Credentials.authorize monkeypatched the request method # of the passed in HTTP object with a wrapper annotated with # @util.positional(1). Since the original method has no such annotation,