@@ -545,7 +545,7 @@ def test_token_refresh_success(self):
545545 ])
546546 http = self .credentials .authorize (http )
547547 resp , content = http .request ('http://example.com' )
548- self .assertEqual ('Bearer 1/3w' , content ['Authorization' ])
548+ self .assertEqual (b 'Bearer 1/3w' , content [b 'Authorization' ])
549549 self .assertFalse (self .credentials .access_token_expired )
550550 self .assertEqual (token_response , self .credentials .token_response )
551551
@@ -615,10 +615,10 @@ def test_no_unicode_in_request_params(self):
615615 http = credentials .authorize (http )
616616 http .request (u'http://example.com' , method = u'GET' , headers = {u'foo' : u'bar' })
617617 for k , v in six .iteritems (http .headers ):
618- self .assertEqual (str , type (k ))
619- self .assertEqual (str , type (v ))
618+ self .assertEqual (six . binary_type , type (k ))
619+ self .assertEqual (six . binary_type , type (v ))
620620
621- # Test again with unicode strings that can't simple be converted to ASCII.
621+ # Test again with unicode strings that can't simply be converted to ASCII.
622622 try :
623623 http .request (
624624 u'http://example.com' , method = u'GET' , headers = {u'foo' : u'\N{COMET} ' })
@@ -707,7 +707,7 @@ def test_auth_header_sent(self):
707707 ])
708708 http = self .credentials .authorize (http )
709709 resp , content = http .request ('http://example.com' )
710- self .assertEqual ('Bearer foo' , content ['Authorization' ])
710+ self .assertEqual (b 'Bearer foo' , content [b 'Authorization' ])
711711
712712
713713class TestAssertionCredentials (unittest .TestCase ):
@@ -738,7 +738,7 @@ def test_assertion_refresh(self):
738738 ])
739739 http = self .credentials .authorize (http )
740740 resp , content = http .request ('http://example.com' )
741- self .assertEqual ('Bearer 1/3w' , content ['Authorization' ])
741+ self .assertEqual (b 'Bearer 1/3w' , content [b 'Authorization' ])
742742
743743 def test_token_revoke_success (self ):
744744 _token_revoke_test_helper (
@@ -769,16 +769,18 @@ class ExtractIdTokenTest(unittest.TestCase):
769769
770770 def test_extract_success (self ):
771771 body = {'foo' : 'bar' }
772- payload = base64 .urlsafe_b64encode (json .dumps (body )).strip ('=' )
773- jwt = 'stuff.' + payload + '.signature'
772+ body_json = json .dumps (body ).encode ('ascii' )
773+ payload = base64 .urlsafe_b64encode (body_json ).strip (b'=' )
774+ jwt = b'stuff.' + payload + b'.signature'
774775
775776 extracted = _extract_id_token (jwt )
776777 self .assertEqual (extracted , body )
777778
778779 def test_extract_failure (self ):
779780 body = {'foo' : 'bar' }
780- payload = base64 .urlsafe_b64encode (json .dumps (body )).strip ('=' )
781- jwt = 'stuff.' + payload
781+ body_json = json .dumps (body ).encode ('ascii' )
782+ payload = base64 .urlsafe_b64encode (body_json ).strip (b'=' )
783+ jwt = b'stuff.' + payload
782784
783785 self .assertRaises (VerifyJwtTokenError , _extract_id_token , jwt )
784786
@@ -840,14 +842,14 @@ def test_exchange_failure(self):
840842
841843 def test_urlencoded_exchange_failure (self ):
842844 http = HttpMockSequence ([
843- ({'status' : '400' }, 'error=invalid_request' ),
845+ ({'status' : '400' }, b 'error=invalid_request' ),
844846 ])
845847
846848 try :
847849 credentials = self .flow .step2_exchange ('some random code' , http = http )
848850 self .fail ('should raise exception if exchange doesn\' t get 200' )
849851 except FlowExchangeError as e :
850- self .assertEquals ('invalid_request' , str (e ))
852+ self .assertEqual ('invalid_request' , str (e ))
851853
852854 def test_exchange_failure_with_json_error (self ):
853855 # Some providers have 'error' attribute as a JSON object
@@ -894,12 +896,12 @@ def __contains__(self, name):
894896
895897 code = 'some random code'
896898 not_a_dict = FakeDict ({'code' : code })
897- http = HttpMockSequence ([
898- ({ 'status' : '200' },
899- """{ "access_token":"SlAV32hkKG",
900- "expires_in":3600,
901- "refresh_token":"8xLOxBtZp8" }""" ),
902- ])
899+ payload = ( b'{'
900+ b' "access_token":"SlAV32hkKG",'
901+ b' "expires_in":3600,'
902+ b' "refresh_token":"8xLOxBtZp8"'
903+ b'}' )
904+ http = HttpMockSequence ([({ 'status' : '200' }, payload ), ])
903905
904906 credentials = self .flow .step2_exchange (not_a_dict , http = http )
905907 self .assertEqual ('SlAV32hkKG' , credentials .access_token )
@@ -972,9 +974,10 @@ def test_exchange_id_token_fail(self):
972974
973975 def test_exchange_id_token (self ):
974976 body = {'foo' : 'bar' }
975- payload = base64 .urlsafe_b64encode (json .dumps (body )).strip ('=' )
976- jwt = (base64 .urlsafe_b64encode ('stuff' )+ '.' + payload + '.' +
977- base64 .urlsafe_b64encode ('signature' ))
977+ body_json = json .dumps (body ).encode ('ascii' )
978+ payload = base64 .urlsafe_b64encode (body_json ).strip (b'=' )
979+ jwt = (base64 .urlsafe_b64encode (b'stuff' ) + b'.' + payload + b'.' +
980+ base64 .urlsafe_b64encode (b'signature' ))
978981
979982 http = HttpMockSequence ([
980983 ({'status' : '200' }, ("""{ "access_token":"SlAV32hkKG",
@@ -994,7 +997,7 @@ def test_flow_from_clientsecrets_cached(self):
994997
995998 flow = flow_from_clientsecrets (
996999 'some_secrets' , '' , redirect_uri = 'oob' , cache = cache_mock )
997- self .assertEquals ('foo_client_secret' , flow .client_secret )
1000+ self .assertEqual ('foo_client_secret' , flow .client_secret )
9981001
9991002
10001003class CredentialsFromCodeTests (unittest .TestCase ):
@@ -1014,7 +1017,7 @@ def test_exchange_code_for_token(self):
10141017 credentials = credentials_from_code (self .client_id , self .client_secret ,
10151018 self .scope , self .code , redirect_uri = self .redirect_uri ,
10161019 http = http )
1017- self .assertEquals (credentials .access_token , token )
1020+ self .assertEqual (credentials .access_token , token )
10181021 self .assertNotEqual (None , credentials .token_expiry )
10191022
10201023 def test_exchange_code_for_token_fail (self ):
@@ -1039,7 +1042,7 @@ def test_exchange_code_and_file_for_token(self):
10391042 credentials = credentials_from_clientsecrets_and_code (
10401043 datafile ('client_secrets.json' ), self .scope ,
10411044 self .code , http = http )
1042- self .assertEquals (credentials .access_token , 'asdfghjkl' )
1045+ self .assertEqual (credentials .access_token , 'asdfghjkl' )
10431046 self .assertNotEqual (None , credentials .token_expiry )
10441047
10451048 def test_exchange_code_and_cached_file_for_token (self ):
@@ -1052,7 +1055,7 @@ def test_exchange_code_and_cached_file_for_token(self):
10521055 credentials = credentials_from_clientsecrets_and_code (
10531056 'some_secrets' , self .scope ,
10541057 self .code , http = http , cache = cache_mock )
1055- self .assertEquals (credentials .access_token , 'asdfghjkl' )
1058+ self .assertEqual (credentials .access_token , 'asdfghjkl' )
10561059
10571060 def test_exchange_code_and_file_for_token_fail (self ):
10581061 http = HttpMockSequence ([
0 commit comments