Skip to content
14 changes: 7 additions & 7 deletions pandas/tests/io/test_gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,25 @@ def mock_read_gbq(sql, **kwargs):

@pytest.mark.single
class TestToGBQIntegrationWithServiceAccountKeyPath:
@staticmethod
def generate_rand_str(length: int = 10) -> str:
return "".join(random.choices(string.ascii_lowercase, k=length))

@pytest.fixture()
def gbq_dataset(self):
# Setup Dataset
_skip_if_no_project_id()
_skip_if_no_private_key_path()

dataset_id = "pydata_pandas_bq_testing_py31"
dataset_id = "pydata_pandas_bq_testing_" + self.generate_rand_str()

self.client = _get_client()
self.dataset = self.client.dataset(dataset_id)
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, are we supposed to clean up these datasets? @tswast

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now just do this here:

self.client.delete_dataset(self.dataset, delete_contents=True)

# Clean-up previous test runs.
self.client.delete_dataset(self.dataset, delete_contents=True)
except api_exceptions.NotFound:
pass # It's OK if the dataset doesn't already exist.

# Create the dataset
self.client.create_dataset(bigquery.Dataset(self.dataset))

table_name = "".join(random.choices(string.ascii_lowercase, k=10))
table_name = self.generate_rand_str()
destination_table = f"{dataset_id}.{table_name}"
yield destination_table

Expand Down