Skip to content

Commit aa081cd

Browse files
committed
Fix a test failure (mismatched error strings).
1 parent 71fa163 commit aa081cd

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

oauth2client/client.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@
7676
# Application Default Credentials.
7777
GOOGLE_APPLICATION_CREDENTIALS = 'GOOGLE_APPLICATION_CREDENTIALS'
7878

79+
# The error message we show users when we can't find the Application
80+
# Default Credentials.
81+
ADC_HELP_MSG = (
82+
'The Application Default Credentials are not available. They are available '
83+
'if running in Google Compute Engine. Otherwise, the environment variable '
84+
+ GOOGLE_APPLICATION_CREDENTIALS +
85+
' must be defined pointing to a file defining the credentials. See '
86+
'https://developers.google.com/accounts/docs/application-default-credentials' # pylint:disable=line-too-long
87+
' for more information.')
88+
7989
# The access token along with the seconds in which it expires.
8090
AccessTokenInfo = collections.namedtuple(
8191
'AccessTokenInfo', ['access_token', 'expires_in'])
@@ -1052,13 +1062,7 @@ def get_application_default():
10521062
elif env_name == 'GCE_PRODUCTION':
10531063
return _get_application_default_credential_GCE()
10541064
else:
1055-
raise ApplicationDefaultCredentialsError(
1056-
'The Application Default Credentials are not available. They are '
1057-
'available if running in Google Compute Engine. Otherwise, the '
1058-
' environment variable ' + GOOGLE_APPLICATION_CREDENTIALS +
1059-
' must be defined pointing to a file defining the credentials. '
1060-
'See https://developers.google.com/accounts/docs/application-default-'
1061-
'credentials for more information.')
1065+
raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
10621066

10631067
@staticmethod
10641068
def from_stream(credential_filename):

tests/test_oauth2client.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from oauth2client.client import AccessTokenCredentials
3939
from oauth2client.client import AccessTokenCredentialsError
4040
from oauth2client.client import AccessTokenRefreshError
41+
from oauth2client.client import ADC_HELP_MSG
4142
from oauth2client.client import AssertionCredentials
4243
from oauth2client.client import AUTHORIZED_USER
4344
from oauth2client.client import Credentials
@@ -421,14 +422,7 @@ def test_get_application_default_environment_not_set_up(self):
421422
GoogleCredentials.get_application_default()
422423
self.fail('An exception was expected!')
423424
except ApplicationDefaultCredentialsError as error:
424-
self.assertEqual(
425-
"The Application Default Credentials are not available. They are "
426-
"available if running in Google Compute Engine. Otherwise, the "
427-
" environment variable " + GOOGLE_APPLICATION_CREDENTIALS +
428-
" must be defined pointing to a file defining the credentials. "
429-
"See https://developers.google.com/accounts/docs/application-default-"
430-
"credentials for more information.",
431-
str(error))
425+
self.assertEqual(ADC_HELP_MSG, str(error))
432426

433427
def test_from_stream_service_account(self):
434428
credentials_file = datafile(

0 commit comments

Comments
 (0)