Skip to content

Commit 8105a7e

Browse files
alimcmaster1jreback
authored andcommitted
CI: Fix Flakey GBQ Tests (#30630)
1 parent 4af0226 commit 8105a7e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pandas/tests/io/test_gbq.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ def _get_client():
6868
return bigquery.Client(project=project_id, credentials=credentials)
6969

7070

71+
def generate_rand_str(length: int = 10) -> str:
72+
return "".join(random.choices(string.ascii_lowercase, k=length))
73+
74+
7175
def make_mixed_dataframe_v2(test_size):
7276
# create df to test for all BQ datatypes except RECORD
7377
bools = np.random.randint(2, size=(1, test_size)).astype(bool)
@@ -153,19 +157,15 @@ def gbq_dataset(self):
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_" + generate_rand_str()
157161

158162
self.client = _get_client()
159163
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.
165164

165+
# Create the dataset
166166
self.client.create_dataset(bigquery.Dataset(self.dataset))
167167

168-
table_name = "".join(random.choices(string.ascii_lowercase, k=10))
168+
table_name = generate_rand_str()
169169
destination_table = f"{dataset_id}.{table_name}"
170170
yield destination_table
171171

0 commit comments

Comments
 (0)