diff --git a/system_tests/bigquery.py b/system_tests/bigquery.py index a1972eb4a2e9..46bc6050fa13 100644 --- a/system_tests/bigquery.py +++ b/system_tests/bigquery.py @@ -263,15 +263,16 @@ def test_load_table_from_storage_then_dump_table(self): self.to_delete.append(bucket) blob = bucket.blob(BLOB_NAME) - self.to_delete.insert(0, blob) - with tempfile.TemporaryFile() as csv_file: + with tempfile.TemporaryFile(mode='w+') as csv_file: writer = csv.writer(csv_file) writer.writerow(('Full Name', 'Age')) writer.writerows(ROWS) blob.upload_from_file( csv_file, rewind=True, content_type='text/csv') + self.to_delete.insert(0, blob) + dataset = CLIENT.dataset(DATASET_NAME) dataset.create() self.to_delete.append(dataset)