@@ -180,18 +180,19 @@ def test_list_datasets(self):
180180
181181 def test_create_table (self ):
182182 dataset = self .temp_dataset (_make_dataset_id ('create_table' ))
183-
184- TABLE_NAME = 'test_table'
183+ table_id = 'test_table'
185184 full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
186185 mode = 'REQUIRED' )
187186 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
188- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
189- client = Config .CLIENT )
190- self .assertFalse (table .exists ())
191- table .create ()
187+ table_arg = Table (dataset .table (table_id ), schema = [full_name , age ],
188+ client = Config .CLIENT )
189+ self .assertFalse (table_arg .exists ())
190+
191+ table = retry_403 (Config .CLIENT .create_table )(table_arg )
192192 self .to_delete .insert (0 , table )
193+
193194 self .assertTrue (table .exists ())
194- self .assertEqual (table .table_id , TABLE_NAME )
195+ self .assertEqual (table .table_id , table_id )
195196
196197 def test_get_table_w_public_dataset (self ):
197198 PUBLIC = 'bigquery-public-data'
@@ -227,10 +228,10 @@ def test_list_dataset_tables(self):
227228 mode = 'REQUIRED' )
228229 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
229230 for table_name in tables_to_create :
230- created_table = Table (dataset .table (table_name ),
231- schema = [full_name , age ],
232- client = Config .CLIENT )
233- created_table . create ( )
231+ table = Table (dataset .table (table_name ),
232+ schema = [full_name , age ],
233+ client = Config .CLIENT )
234+ created_table = retry_403 ( Config . CLIENT . create_table )( table )
234235 self .to_delete .insert (0 , created_table )
235236
236237 # Retrieve the tables.
@@ -249,10 +250,10 @@ def test_patch_table(self):
249250 full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
250251 mode = 'REQUIRED' )
251252 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
252- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
253- client = Config .CLIENT )
254- self .assertFalse (table .exists ())
255- table . create ( )
253+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
254+ client = Config .CLIENT )
255+ self .assertFalse (table_arg .exists ())
256+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
256257 self .to_delete .insert (0 , table )
257258 self .assertTrue (table .exists ())
258259 self .assertIsNone (table .friendly_name )
@@ -268,10 +269,10 @@ def test_update_table(self):
268269 full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
269270 mode = 'REQUIRED' )
270271 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
271- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
272- client = Config .CLIENT )
273- self .assertFalse (table .exists ())
274- table . create ( )
272+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
273+ client = Config .CLIENT )
274+ self .assertFalse (table_arg .exists ())
275+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
275276 self .to_delete .insert (0 , table )
276277 self .assertTrue (table .exists ())
277278 voter = bigquery .SchemaField ('voter' , 'BOOLEAN' , mode = 'NULLABLE' )
@@ -309,10 +310,10 @@ def test_insert_data_then_dump_table(self):
309310 mode = 'REQUIRED' )
310311 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
311312 now = bigquery .SchemaField ('now' , 'TIMESTAMP' )
312- table = Table (dataset .table (TABLE_NAME ), schema = [ full_name , age , now ] ,
313- client = Config .CLIENT )
314- self .assertFalse (table .exists ())
315- table . create ( )
313+ table_arg = Table (dataset .table (TABLE_NAME ),
314+ schema = [ full_name , age , now ], client = Config .CLIENT )
315+ self .assertFalse (table_arg .exists ())
316+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
316317 self .to_delete .insert (0 , table )
317318 self .assertTrue (table .exists ())
318319
@@ -346,9 +347,9 @@ def test_load_table_from_local_file_then_dump_table(self):
346347 full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
347348 mode = 'REQUIRED' )
348349 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
349- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
350- client = Config .CLIENT )
351- table . create ( )
350+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
351+ client = Config .CLIENT )
352+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
352353 self .to_delete .insert (0 , table )
353354
354355 with _NamedTemporaryFile () as temp :
@@ -450,9 +451,9 @@ def test_load_table_from_storage_then_dump_table(self):
450451 full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
451452 mode = 'REQUIRED' )
452453 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
453- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
454- client = Config .CLIENT )
455- table . create ( )
454+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
455+ client = Config .CLIENT )
456+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
456457 self .to_delete .insert (0 , table )
457458
458459 job = Config .CLIENT .load_table_from_storage (
@@ -652,9 +653,9 @@ def test_job_cancel(self):
652653 full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
653654 mode = 'REQUIRED' )
654655 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
655- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
656- client = Config .CLIENT )
657- table . create ( )
656+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
657+ client = Config .CLIENT )
658+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
658659 self .to_delete .insert (0 , table )
659660
660661 job = Config .CLIENT .run_async_query (JOB_NAME , QUERY )
@@ -839,9 +840,9 @@ def _load_table_for_dml(self, rows, dataset_id, table_id):
839840 dataset = self .temp_dataset (dataset_id )
840841 greeting = bigquery .SchemaField (
841842 'greeting' , 'STRING' , mode = 'NULLABLE' )
842- table = Table (dataset .table (table_id ), schema = [greeting ],
843- client = Config .CLIENT )
844- table . create ( )
843+ table_arg = Table (dataset .table (table_id ), schema = [greeting ],
844+ client = Config .CLIENT )
845+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
845846 self .to_delete .insert (0 , table )
846847
847848 with _NamedTemporaryFile () as temp :
@@ -1228,9 +1229,9 @@ def test_insert_nested_nested(self):
12281229 ]
12291230 table_name = 'test_table'
12301231 dataset = self .temp_dataset (_make_dataset_id ('issue_2951' ))
1231- table = Table (dataset .table (table_name ), schema = schema ,
1232- client = Config .CLIENT )
1233- table . create ( )
1232+ table_arg = Table (dataset .table (table_name ), schema = schema ,
1233+ client = Config .CLIENT )
1234+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
12341235 self .to_delete .insert (0 , table )
12351236
12361237 table .insert_data (to_insert )
@@ -1245,9 +1246,9 @@ def test_create_table_insert_fetch_nested_schema(self):
12451246 dataset = self .temp_dataset (
12461247 _make_dataset_id ('create_table_nested_schema' ))
12471248 schema = _load_json_schema ()
1248- table = Table (dataset .table (table_name ), schema = schema ,
1249- client = Config .CLIENT )
1250- table . create ( )
1249+ table_arg = Table (dataset .table (table_name ), schema = schema ,
1250+ client = Config .CLIENT )
1251+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
12511252 self .to_delete .insert (0 , table )
12521253 self .assertTrue (table .exists ())
12531254 self .assertEqual (table .table_id , table_name )
0 commit comments