Skip to content

Commit a91b8a3

Browse files
committed
Give dataset random name
1 parent 5e94956 commit a91b8a3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pandas/tests/io/test_gbq.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -147,26 +147,30 @@ def mock_read_gbq(sql, **kwargs):
147147

148148
@pytest.mark.single
149149
class TestToGBQIntegrationWithServiceAccountKeyPath:
150+
@staticmethod
151+
def generate_rand_str(length: int = 10) -> str:
152+
return "".join(random.choices(string.ascii_lowercase, k=length))
153+
150154
@pytest.fixture()
151155
def gbq_dataset(self):
152156
# Setup Dataset
153157
_skip_if_no_project_id()
154158
_skip_if_no_private_key_path()
155159

156-
dataset_id = "pydata_pandas_bq_testing_py31"
160+
dataset_id = "pydata_pandas_bq_testing_" + self.generate_rand_str()
157161

158162
self.client = _get_client()
159163
self.dataset = self.client.dataset(dataset_id)
160164

161-
# Create the dataset if it doesn't already exist
162-
self.client.create_dataset(bigquery.Dataset(self.dataset), exists_ok=True)
165+
# Create the dataset
166+
self.client.create_dataset(bigquery.Dataset(self.dataset))
163167

164-
table_name = "".join(random.choices(string.ascii_lowercase, k=10))
168+
table_name = self.generate_rand_str()
165169
destination_table = f"{dataset_id}.{table_name}"
166170
yield destination_table
167171

168-
# Teardown tables created
169-
self.client.delete_table(destination_table, not_found_ok=True)
172+
# Teardown Dataset
173+
self.client.delete_dataset(self.dataset, delete_contents=True)
170174

171175
def test_roundtrip(self, gbq_dataset):
172176
destination_table = gbq_dataset

0 commit comments

Comments
 (0)