@@ -864,7 +864,7 @@ def test_cancel_w_custom_retry(self):
864864job = self ._set_properties_job ()
865865
866866api_request_patcher = mock .patch .object (
867- job ._client ._connection ,"api_request" ,side_effect = [ValueError ,response ],
867+ job ._client ._connection ,"api_request" ,side_effect = [ValueError ,response ]
868868 )
869869retry = DEFAULT_RETRY .with_deadline (1 ).with_predicate (
870870lambda exc :isinstance (exc ,ValueError )
@@ -885,7 +885,7 @@ def test_cancel_w_custom_retry(self):
885885 [
886886mock .call (method = "POST" ,path = api_path ,query_params = {},timeout = 7.5 ),
887887mock .call (
888- method = "POST" ,path = api_path ,query_params = {},timeout = 7.5 ,
888+ method = "POST" ,path = api_path ,query_params = {},timeout = 7.5
889889 ),# was retried once
890890 ],
891891 )
@@ -1034,7 +1034,6 @@ def test_result_w_retry_wo_state(self):
10341034custom_predicate = mock .Mock ()
10351035custom_predicate .return_value = True
10361036custom_retry = google .api_core .retry .Retry (predicate = custom_predicate )
1037-
10381037self .assertIs (job .result (retry = custom_retry ),job )
10391038
10401039begin_call = mock .call (
@@ -2757,7 +2756,7 @@ def test_cancel_w_bound_client(self):
27572756final_attributes .assert_called_with ({"path" :PATH },client ,job )
27582757
27592758conn .api_request .assert_called_once_with (
2760- method = "POST" ,path = PATH ,query_params = {},timeout = None ,
2759+ method = "POST" ,path = PATH ,query_params = {},timeout = None
27612760 )
27622761self ._verifyResourceProperties (job ,RESOURCE )
27632762
@@ -2779,7 +2778,7 @@ def test_cancel_w_alternate_client(self):
27792778
27802779conn1 .api_request .assert_not_called ()
27812780conn2 .api_request .assert_called_once_with (
2782- method = "POST" ,path = PATH ,query_params = {},timeout = None ,
2781+ method = "POST" ,path = PATH ,query_params = {},timeout = None
27832782 )
27842783self ._verifyResourceProperties (job ,RESOURCE )
27852784
@@ -3205,7 +3204,7 @@ def test_exists_miss_w_bound_client(self):
32053204final_attributes .assert_called_with ({"path" :PATH },client ,job )
32063205
32073206conn .api_request .assert_called_once_with (
3208- method = "GET" ,path = PATH ,query_params = {"fields" :"id" },timeout = None ,
3207+ method = "GET" ,path = PATH ,query_params = {"fields" :"id" },timeout = None
32093208 )
32103209
32113210def test_exists_hit_w_alternate_client (self ):
@@ -3620,7 +3619,7 @@ def test_exists_miss_w_bound_client(self):
36203619final_attributes .assert_called_with ({"path" :PATH },client ,job )
36213620
36223621conn .api_request .assert_called_once_with (
3623- method = "GET" ,path = PATH ,query_params = {"fields" :"id" },timeout = None ,
3622+ method = "GET" ,path = PATH ,query_params = {"fields" :"id" },timeout = None
36243623 )
36253624
36263625def test_exists_hit_w_alternate_client (self ):
@@ -4812,6 +4811,60 @@ def test_result_with_max_results(self):
48124811tabledata_list_request [1 ]["query_params" ]["maxResults" ],max_results
48134812 )
48144813
4814+ def test_result_w_retry (self ):
4815+ from google .cloud .bigquery .table import RowIterator
4816+
4817+ query_resource = {
4818+ "jobComplete" :False ,
4819+ "jobReference" : {"projectId" :self .PROJECT ,"jobId" :self .JOB_ID },
4820+ }
4821+ query_resource_done = {
4822+ "jobComplete" :True ,
4823+ "jobReference" : {"projectId" :self .PROJECT ,"jobId" :self .JOB_ID },
4824+ "schema" : {"fields" : [{"name" :"col1" ,"type" :"STRING" }]},
4825+ "totalRows" :"2" ,
4826+ }
4827+ job_resource = self ._make_resource (started = True )
4828+ job_resource_done = self ._make_resource (started = True ,ended = True )
4829+ job_resource_done ["configuration" ]["query" ]["destinationTable" ]= {
4830+ "projectId" :"dest-project" ,
4831+ "datasetId" :"dest_dataset" ,
4832+ "tableId" :"dest_table" ,
4833+ }
4834+
4835+ connection = _make_connection (
4836+ exceptions .NotFound ("not normally retriable" ),
4837+ query_resource ,
4838+ exceptions .NotFound ("not normally retriable" ),
4839+ query_resource_done ,
4840+ exceptions .NotFound ("not normally retriable" ),
4841+ job_resource_done ,
4842+ )
4843+ client = _make_client (self .PROJECT ,connection = connection )
4844+ job = self ._get_target_class ().from_api_repr (job_resource ,client )
4845+
4846+ custom_predicate = mock .Mock ()
4847+ custom_predicate .return_value = True
4848+ custom_retry = google .api_core .retry .Retry (predicate = custom_predicate )
4849+
4850+ self .assertIsInstance (job .result (retry = custom_retry ),RowIterator )
4851+ query_results_call = mock .call (
4852+ method = "GET" ,
4853+ path = f"/projects/{ self .PROJECT } /queries/{ self .JOB_ID } " ,
4854+ query_params = {"maxResults" :0 },
4855+ timeout = None ,
4856+ )
4857+ reload_call = mock .call (
4858+ method = "GET" ,
4859+ path = f"/projects/{ self .PROJECT } /jobs/{ self .JOB_ID } " ,
4860+ query_params = {},
4861+ timeout = None ,
4862+ )
4863+
4864+ connection .api_request .assert_has_calls (
4865+ [query_results_call ,query_results_call ,reload_call ]
4866+ )
4867+
48154868def test_result_w_empty_schema (self ):
48164869from google .cloud .bigquery .table import _EmptyRowIterator
48174870