From 3415b2e52b9aecf02f12ee62fa8103e3a9dee778 Mon Sep 17 00:00:00 2001 From: Naoto Nishizono Date: Thu, 19 Mar 2015 16:06:15 +0900 Subject: [PATCH] Fix error handling of reset method in s3_test_client.py This patch fix error handling of reset method in s3_test_client.py. Exceptions that occurred in reset method are S3ResponseError. So, error handling is done according to the status of S3ResponseError. Change-Id: I6718f0c492213912052f40a4c6ed194ecf0b1fd0 --- swift3/test/functional/s3_test_client.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/swift3/test/functional/s3_test_client.py b/swift3/test/functional/s3_test_client.py index 3c03c673..fbfb59a2 100644 --- a/swift3/test/functional/s3_test_client.py +++ b/swift3/test/functional/s3_test_client.py @@ -16,7 +16,6 @@ import os from boto.s3.connection import S3Connection, OrdinaryCallingFormat, \ BotoClientError, S3ResponseError -from swift3.response import NoSuchKey, NoSuchBucket RETRY_COUNT = 3 @@ -65,16 +64,16 @@ class Connection(object): buckets = self.conn.get_all_buckets() if not buckets: break + for bucket in buckets: - for obj in bucket.list(): - try: - bucket.delete_key(obj.name) - except NoSuchKey: - pass try: + for obj in bucket.list(): + bucket.delete_key(obj.name) self.conn.delete_bucket(bucket.name) - except NoSuchBucket: - pass + except S3ResponseError as e: + # 404 means NoSuchBucket or NoSuchKey + if e.status != 404: + raise except (BotoClientError, S3ResponseError) as e: exceptions.append(e) if exceptions: