Skip to content

Commit

Permalink
Making sure delete does not fail in regression tests.
Browse files Browse the repository at this point in the history
Fixes googleapis#531. See googleapis#535 for context.
  • Loading branch information
dhermes committed Jan 22, 2015
1 parent 927c534 commit 0b90362
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions regression/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,20 @@ def setUpModule():
SHARED_BUCKETS['test_bucket'] = connection.create_bucket(bucket_name)


def safe_delete(bucket):
for key in bucket:
try:
key.delete()
except storage.exceptions.NotFound:
print('Delete failed with 404: %r' % (key,))

# Passing force=False does not try to delete the contained files.
bucket.delete(force=False)


def tearDownModule():
for bucket in SHARED_BUCKETS.values():
# Passing force=True also deletes all files.
bucket.delete(force=True)
safe_delete(bucket)


class TestStorage(unittest2.TestCase):
Expand Down

0 comments on commit 0b90362

Please sign in to comment.