1414
1515import copy
1616import sys
17+
1718if sys .version_info >= (3 , 8 ):
1819 from unittest import mock
1920 from unittest .mock import AsyncMock
@@ -220,7 +221,9 @@ async def test__obtain_rapt_unsupported_status():
220221 challenges_response = copy .deepcopy (CHALLENGES_RESPONSE_TEMPLATE )
221222 challenges_response ["status" ] = "STATUS_UNSPECIFIED"
222223 with mock .patch (
223- "google.oauth2._reauth_async._get_challenges" , new_callable = AsyncMock , return_value = challenges_response
224+ "google.oauth2._reauth_async._get_challenges" ,
225+ new_callable = AsyncMock ,
226+ return_value = challenges_response ,
224227 ):
225228 with pytest .raises (exceptions .ReauthFailError ) as excinfo :
226229 await _reauth_async ._obtain_rapt (MOCK_REQUEST , "token" , None )
@@ -261,7 +264,9 @@ async def test_get_rapt_token():
261264 return_value = ("token" , None , None , None ),
262265 ) as mock_refresh_grant :
263266 with mock .patch (
264- "google.oauth2._reauth_async._obtain_rapt" , new_callable = AsyncMock , return_value = "new_rapt_token"
267+ "google.oauth2._reauth_async._obtain_rapt" ,
268+ new_callable = AsyncMock ,
269+ return_value = "new_rapt_token" ,
265270 ) as mock_obtain_rapt :
266271 assert (
267272 await _reauth_async .get_rapt_token (
@@ -289,7 +294,8 @@ async def test_get_rapt_token():
289294@pytest .mark .asyncio
290295async def test_refresh_grant_failed ():
291296 with mock .patch (
292- "google.oauth2._client_async._token_endpoint_request_no_throw" , new_callable = AsyncMock
297+ "google.oauth2._client_async._token_endpoint_request_no_throw" ,
298+ new_callable = AsyncMock ,
293299 ) as mock_token_request :
294300 mock_token_request .return_value = (False , {"error" : "Bad request" }, True )
295301 with pytest .raises (exceptions .RefreshError ) as excinfo :
@@ -321,14 +327,17 @@ async def test_refresh_grant_failed():
321327@pytest .mark .asyncio
322328async def test_refresh_grant_success ():
323329 with mock .patch (
324- "google.oauth2._client_async._token_endpoint_request_no_throw" , new_callable = AsyncMock
330+ "google.oauth2._client_async._token_endpoint_request_no_throw" ,
331+ new_callable = AsyncMock ,
325332 ) as mock_token_request :
326333 mock_token_request .side_effect = [
327334 (False , {"error" : "invalid_grant" , "error_subtype" : "rapt_required" }, True ),
328335 (True , {"access_token" : "access_token" }, None ),
329336 ]
330337 with mock .patch (
331- "google.oauth2._reauth_async.get_rapt_token" , new_callable = AsyncMock , return_value = "new_rapt_token"
338+ "google.oauth2._reauth_async.get_rapt_token" ,
339+ new_callable = AsyncMock ,
340+ return_value = "new_rapt_token" ,
332341 ):
333342 assert await _reauth_async .refresh_grant (
334343 MOCK_REQUEST ,
@@ -349,7 +358,8 @@ async def test_refresh_grant_success():
349358@pytest .mark .asyncio
350359async def test_refresh_grant_reauth_refresh_disabled ():
351360 with mock .patch (
352- "google.oauth2._client_async._token_endpoint_request_no_throw" , new_callable = AsyncMock
361+ "google.oauth2._client_async._token_endpoint_request_no_throw" ,
362+ new_callable = AsyncMock ,
353363 ) as mock_token_request :
354364 mock_token_request .side_effect = [
355365 (
0 commit comments