Skip to content

Commit c4a9830

Browse files
committed
Don't Error if Dataset Exists
1 parent 3bf5aed commit c4a9830

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pandas/tests/io/test_gbq.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ def gbq_dataset(self):
157157

158158
self.client = _get_client()
159159
self.dataset = self.client.dataset(dataset_id)
160-
try:
161-
# Clean-up previous test runs.
162-
self.client.delete_dataset(self.dataset, delete_contents=True)
163-
except api_exceptions.NotFound:
164-
pass # It's OK if the dataset doesn't already exist.
165160

166-
self.client.create_dataset(bigquery.Dataset(self.dataset))
161+
# Ensure previous test runs are removed
162+
self.client.delete_dataset(
163+
self.dataset, delete_contents=True, not_found_ok=True
164+
)
165+
166+
self.client.create_dataset(bigquery.Dataset(self.dataset), exists_ok=True)
167167

168168
table_name = "".join(random.choices(string.ascii_lowercase, k=10))
169169
destination_table = f"{dataset_id}.{table_name}"

0 commit comments

Comments
 (0)