@@ -192,12 +192,12 @@ def test_create_table(self):
192192 age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
193193 table_arg = Table (dataset .table (table_id ), schema = [full_name , age ],
194194 client = Config .CLIENT )
195- self .assertFalse (table_arg . exists ( ))
195+ self .assertFalse (_table_exists ( table_arg ))
196196
197197 table = retry_403 (Config .CLIENT .create_table )(table_arg )
198198 self .to_delete .insert (0 , table )
199199
200- self .assertTrue (table . exists ( ))
200+ self .assertTrue (_table_exists ( table ))
201201 self .assertEqual (table .table_id , table_id )
202202
203203 def test_get_table_w_public_dataset (self ):
@@ -259,10 +259,10 @@ def test_update_table(self):
259259 ]
260260 table_arg = Table (dataset .table (TABLE_NAME ), schema = schema ,
261261 client = Config .CLIENT )
262- self .assertFalse (table_arg . exists ( ))
262+ self .assertFalse (_table_exists ( table_arg ))
263263 table = retry_403 (Config .CLIENT .create_table )(table_arg )
264264 self .to_delete .insert (0 , table )
265- self .assertTrue (table . exists ( ))
265+ self .assertTrue (_table_exists ( table ))
266266 self .assertIsNone (table .friendly_name )
267267 self .assertIsNone (table .description )
268268 table .friendly_name = 'Friendly'
@@ -294,10 +294,10 @@ def test_update_table_schema(self):
294294 ]
295295 table_arg = Table (dataset .table (TABLE_NAME ), schema = schema ,
296296 client = Config .CLIENT )
297- self .assertFalse (table_arg . exists ( ))
297+ self .assertFalse (_table_exists ( table_arg ))
298298 table = retry_403 (Config .CLIENT .create_table )(table_arg )
299299 self .to_delete .insert (0 , table )
300- self .assertTrue (table . exists ( ))
300+ self .assertTrue (_table_exists ( table ))
301301 voter = bigquery .SchemaField ('voter' , 'BOOLEAN' , mode = 'NULLABLE' )
302302 schema = table .schema
303303 schema .append (voter )
@@ -338,10 +338,10 @@ def test_insert_data_then_dump_table(self):
338338 now = bigquery .SchemaField ('now' , 'TIMESTAMP' )
339339 table_arg = Table (dataset .table (TABLE_NAME ),
340340 schema = [full_name , age , now ], client = Config .CLIENT )
341- self .assertFalse (table_arg . exists ( ))
341+ self .assertFalse (_table_exists ( table_arg ))
342342 table = retry_403 (Config .CLIENT .create_table )(table_arg )
343343 self .to_delete .insert (0 , table )
344- self .assertTrue (table . exists ( ))
344+ self .assertTrue (_table_exists ( table ))
345345
346346 errors = table .insert_data (ROWS , ROW_IDS )
347347 self .assertEqual (len (errors ), 0 )
@@ -1317,7 +1317,7 @@ def test_create_table_insert_fetch_nested_schema(self):
13171317 client = Config .CLIENT )
13181318 table = retry_403 (Config .CLIENT .create_table )(table_arg )
13191319 self .to_delete .insert (0 , table )
1320- self .assertTrue (table . exists ( ))
1320+ self .assertTrue (_table_exists ( table ))
13211321 self .assertEqual (table .table_id , table_name )
13221322
13231323 to_insert = []
@@ -1386,3 +1386,12 @@ def _dataset_exists(ds):
13861386 return True
13871387 except NotFound :
13881388 return False
1389+
1390+
1391+ def _table_exists (t ):
1392+ try :
1393+ tr = DatasetReference (t .project , t .dataset_id ).table (t .table_id )
1394+ Config .CLIENT .get_table (tr )
1395+ return True
1396+ except NotFound :
1397+ return False
0 commit comments