16
16
import pytest
17
17
import pytz
18
18
19
- from pandas_gbq import exceptions , gbq
19
+ from pandas_gbq import gbq
20
20
import pandas_gbq .schema
21
21
22
22
TABLE_ID = "new_test"
@@ -195,7 +195,7 @@ def test_read_gbq_raises_invalid_column_order(self, project_id):
195
195
col_order = ["string_aaa" , "string_1" , "string_2" ]
196
196
197
197
# Column string_aaa does not exist. Should raise InvalidColumnOrder
198
- with pytest .raises (exceptions .InvalidColumnOrder ):
198
+ with pytest .raises (gbq .InvalidColumnOrder ):
199
199
gbq .read_gbq (
200
200
query ,
201
201
project_id = project_id ,
@@ -227,7 +227,7 @@ def test_read_gbq_raises_invalid_index_column(self, project_id):
227
227
col_order = ["string_3" , "string_2" ]
228
228
229
229
# Column string_bbb does not exist. Should raise InvalidIndexColumn
230
- with pytest .raises (exceptions .InvalidIndexColumn ):
230
+ with pytest .raises (gbq .InvalidIndexColumn ):
231
231
gbq .read_gbq (
232
232
query ,
233
233
project_id = project_id ,
@@ -238,7 +238,7 @@ def test_read_gbq_raises_invalid_index_column(self, project_id):
238
238
)
239
239
240
240
def test_malformed_query (self , project_id ):
241
- with pytest .raises (exceptions .GenericGBQException ):
241
+ with pytest .raises (gbq .GenericGBQException ):
242
242
gbq .read_gbq (
243
243
"SELCET * FORM [publicdata:samples.shakespeare]" ,
244
244
project_id = project_id ,
@@ -247,7 +247,7 @@ def test_malformed_query(self, project_id):
247
247
)
248
248
249
249
def test_bad_project_id (self ):
250
- with pytest .raises (exceptions .GenericGBQException ):
250
+ with pytest .raises (gbq .GenericGBQException ):
251
251
gbq .read_gbq (
252
252
"SELCET * FROM [publicdata:samples.shakespeare]" ,
253
253
project_id = "not-my-project" ,
@@ -256,7 +256,7 @@ def test_bad_project_id(self):
256
256
)
257
257
258
258
def test_bad_table_name (self , project_id ):
259
- with pytest .raises (exceptions .GenericGBQException ):
259
+ with pytest .raises (gbq .GenericGBQException ):
260
260
gbq .read_gbq (
261
261
"SELECT * FROM [publicdata:samples.nope]" ,
262
262
project_id = project_id ,
@@ -316,7 +316,7 @@ def test_legacy_sql(self, project_id):
316
316
317
317
# Test that a legacy sql statement fails when
318
318
# setting dialect='standard'
319
- with pytest .raises (exceptions .GenericGBQException ):
319
+ with pytest .raises (gbq .GenericGBQException ):
320
320
gbq .read_gbq (
321
321
legacy_sql ,
322
322
project_id = project_id ,
@@ -341,7 +341,7 @@ def test_standard_sql(self, project_id):
341
341
342
342
# Test that a standard sql statement fails when using
343
343
# the legacy SQL dialect.
344
- with pytest .raises (exceptions .GenericGBQException ):
344
+ with pytest .raises (gbq .GenericGBQException ):
345
345
gbq .read_gbq (
346
346
standard_sql ,
347
347
project_id = project_id ,
@@ -485,7 +485,7 @@ def test_timeout_configuration(self, project_id):
485
485
{"query" : {"useQueryCache" : False }, "jobTimeoutMs" : 401 },
486
486
]
487
487
for config in configs :
488
- with pytest .raises (exceptions .QueryTimeout ):
488
+ with pytest .raises (gbq .QueryTimeout ):
489
489
gbq .read_gbq (
490
490
sql_statement ,
491
491
project_id = project_id ,
@@ -507,7 +507,7 @@ def test_timeout_configuration(self, project_id):
507
507
]
508
508
509
509
for config in configs :
510
- with pytest .raises (exceptions .QueryTimeout ):
510
+ with pytest .raises (gbq .QueryTimeout ):
511
511
gbq .read_gbq (
512
512
sql_statement ,
513
513
project_id = project_id ,
@@ -741,7 +741,7 @@ def test_upload_data_if_table_exists_fail(self, project_id):
741
741
)
742
742
743
743
# Test the default value of if_exists == 'fail'
744
- with pytest .raises (exceptions .TableCreationError ):
744
+ with pytest .raises (gbq .TableCreationError ):
745
745
gbq .to_gbq (
746
746
df ,
747
747
self .destination_table + test_id ,
@@ -750,7 +750,7 @@ def test_upload_data_if_table_exists_fail(self, project_id):
750
750
)
751
751
752
752
# Test the if_exists parameter with value 'fail'
753
- with pytest .raises (exceptions .TableCreationError ):
753
+ with pytest .raises (gbq .TableCreationError ):
754
754
gbq .to_gbq (
755
755
df ,
756
756
self .destination_table + test_id ,
@@ -794,7 +794,7 @@ def test_upload_data_if_table_exists_append(self, project_id):
794
794
assert result ["num_rows" ][0 ] == test_size * 2
795
795
796
796
# Try inserting with a different schema, confirm failure
797
- with pytest .raises (exceptions .InvalidSchema ):
797
+ with pytest .raises (gbq .InvalidSchema ):
798
798
gbq .to_gbq (
799
799
df_different_schema ,
800
800
self .destination_table + test_id ,
@@ -1029,7 +1029,7 @@ def test_upload_data_with_invalid_user_schema_raises_error(self, project_id):
1029
1029
{"name" : "D" , "type" : "FLOAT" },
1030
1030
]
1031
1031
destination_table = self .destination_table + test_id
1032
- with pytest .raises (exceptions .GenericGBQException ):
1032
+ with pytest .raises (gbq .GenericGBQException ):
1033
1033
gbq .to_gbq (
1034
1034
df ,
1035
1035
destination_table ,
@@ -1047,7 +1047,7 @@ def test_upload_data_with_missing_schema_fields_raises_error(self, project_id):
1047
1047
{"name" : "C" , "type" : "FLOAT" },
1048
1048
]
1049
1049
destination_table = self .destination_table + test_id
1050
- with pytest .raises (exceptions .GenericGBQException ):
1050
+ with pytest .raises (gbq .GenericGBQException ):
1051
1051
gbq .to_gbq (
1052
1052
df ,
1053
1053
destination_table ,
@@ -1193,7 +1193,7 @@ def test_create_dataset(bigquery_client, gbq_dataset, random_dataset_id, project
1193
1193
1194
1194
def test_create_dataset_already_exists (gbq_dataset , random_dataset_id ):
1195
1195
gbq_dataset .create (random_dataset_id )
1196
- with pytest .raises (exceptions .DatasetCreationError ):
1196
+ with pytest .raises (gbq .DatasetCreationError ):
1197
1197
gbq_dataset .create (random_dataset_id )
1198
1198
1199
1199
@@ -1218,7 +1218,7 @@ def test_create_table(gbq_table):
1218
1218
def test_create_table_already_exists (gbq_table ):
1219
1219
schema = gbq ._generate_bq_schema (make_mixed_dataframe_v1 ())
1220
1220
gbq_table .create ("test_create_table_exists" , schema )
1221
- with pytest .raises (exceptions .TableCreationError ):
1221
+ with pytest .raises (gbq .TableCreationError ):
1222
1222
gbq_table .create ("test_create_table_exists" , schema )
1223
1223
1224
1224
0 commit comments