1717
1818import pytest
1919import requests .exceptions
20- from google .api_core import exceptions as core_exceptions
2120from google .cloud import bigquery
2221
22+
2323def test_insert_rows_json_ssl_error_no_retry (bigquery_client , dataset_id , project_id ):
2424 """
2525 Verify that SSLError during insert_rows_json is NOT retried and
@@ -32,25 +32,23 @@ def test_insert_rows_json_ssl_error_no_retry(bigquery_client, dataset_id, projec
3232 try :
3333 # We mock the api_request to simulate the GFE abruptly closing the connection
3434 # which manifests as a requests.exceptions.SSLError.
35- original_api_request = bigquery_client ._connection .api_request
35+ bigquery_client ._connection .api_request
3636 call_count = 0
3737
3838 def mock_api_request (* args , ** kwargs ):
3939 nonlocal call_count
4040 call_count += 1
4141 raise requests .exceptions .SSLError ("EOF occurred in violation of protocol" )
4242
43- with mock .patch .object (bigquery_client ._connection , "api_request" , side_effect = mock_api_request ):
43+ with mock .patch .object (
44+ bigquery_client ._connection , "api_request" , side_effect = mock_api_request
45+ ):
4446 # Use a reasonably short deadline for the test, although it should fail on the first attempt anyway.
4547 retry = bigquery .DEFAULT_RETRY .with_deadline (5.0 )
4648
4749 start_time = time .time ()
4850 with pytest .raises (requests .exceptions .SSLError ) as excinfo :
49- bigquery_client .insert_rows_json (
50- table ,
51- [{"name" : "test" }],
52- retry = retry
53- )
51+ bigquery_client .insert_rows_json (table , [{"name" : "test" }], retry = retry )
5452 duration = time .time () - start_time
5553
5654 # Verification:
0 commit comments