def test_get_adc_from_env_var_malformed_file(self, *stubs):
# Set up stubs.
get_well_known, get_env_file, in_gae, in_gce = stubs
get_env_file.return_value = datafile(
os.path.join('gcloud',
'application_default_credentials_malformed_3.json'))
expected_err = client.ApplicationDefaultCredentialsError
with self.assertRaises(expected_err) as exc_manager:
client.GoogleCredentials.get_application_default()
self.assertTrue(str(exc_manager.exception).startswith(
'An error was encountered while reading json file: ' +
get_env_file.return_value + ' (pointed to by ' +
client.GOOGLE_APPLICATION_CREDENTIALS + ' environment variable):'))
get_env_file.assert_called_once_with()
get_well_known.assert_not_called()
in_gae.assert_not_called()
in_gce.assert_not_called()
评论列表
文章目录