@@ -4356,14 +4356,15 @@ def _call_fut(error):
4356
4356
4357
4357
return _raise_from_invalid_response (error )
4358
4358
4359
- def _helper (self , message , code = http_client .BAD_REQUEST , args = ()):
4359
+ def _helper (self , message , code = http_client .BAD_REQUEST , reason = None , args = ()):
4360
4360
import requests
4361
4361
4362
4362
from google .resumable_media import InvalidResponse
4363
4363
from google .api_core import exceptions
4364
4364
4365
4365
response = requests .Response ()
4366
4366
response .request = requests .Request ("GET" , "http://example.com" ).prepare ()
4367
+ response ._content = reason
4367
4368
response .status_code = code
4368
4369
error = InvalidResponse (response , message , * args )
4369
4370
@@ -4381,9 +4382,14 @@ def test_default(self):
4381
4382
4382
4383
def test_w_206_and_args (self ):
4383
4384
message = "Failure"
4385
+ reason = b"Not available"
4384
4386
args = ("one" , "two" )
4385
- exc_info = self ._helper (message , code = http_client .PARTIAL_CONTENT , args = args )
4386
- expected = "GET http://example.com/: {}" .format ((message ,) + args )
4387
+ exc_info = self ._helper (
4388
+ message , code = http_client .PARTIAL_CONTENT , reason = reason , args = args
4389
+ )
4390
+ expected = "GET http://example.com/: {}: {}" .format (
4391
+ reason .decode ("utf-8" ), (message ,) + args
4392
+ )
4387
4393
self .assertEqual (exc_info .exception .message , expected )
4388
4394
self .assertEqual (exc_info .exception .errors , [])
4389
4395
0 commit comments