3030from retry import RetryErrors
3131
3232
33+ retry_429 = RetryErrors (exceptions .TooManyRequests )
3334HTTP = httplib2 .Http ()
3435_helpers .PROJECT = TESTS_PROJECT
3536
@@ -49,7 +50,8 @@ def setUpModule():
4950 bucket_name = 'new' + unique_resource_id ()
5051 # In the **very** rare case the bucket name is reserved, this
5152 # fails with a ConnectionError.
52- Config .TEST_BUCKET = Config .CLIENT .create_bucket (bucket_name )
53+ Config .TEST_BUCKET = Config .CLIENT .bucket (bucket_name )
54+ retry_429 (Config .TEST_BUCKET .create )()
5355
5456
5557def tearDownModule ():
@@ -65,7 +67,8 @@ def setUp(self):
6567 def tearDown (self ):
6668 with Config .CLIENT .batch ():
6769 for bucket_name in self .case_buckets_to_delete :
68- Config .CLIENT .bucket (bucket_name ).delete ()
70+ bucket = Config .CLIENT .bucket (bucket_name )
71+ retry_429 (bucket .delete )()
6972
7073 def test_create_bucket (self ):
7174 new_bucket_name = 'a-new-bucket' + unique_resource_id ('-' )
@@ -83,7 +86,8 @@ def test_list_buckets(self):
8386 ]
8487 created_buckets = []
8588 for bucket_name in buckets_to_create :
86- bucket = Config .CLIENT .create_bucket (bucket_name )
89+ bucket = Config .CLIENT .bucket (bucket_name )
90+ retry_429 (bucket .create )()
8791 self .case_buckets_to_delete .append (bucket_name )
8892
8993 # Retrieve the buckets.
0 commit comments