File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1616import pytest
1717import re
1818import time
19+ import uuid
1920
2021import storage_remove_bucket_iam_member
2122import storage_add_bucket_iam_member
3233
3334@pytest .fixture
3435def bucket ():
35- bucket_name = "test-iam-" + str (int (time .time ()))
36- bucket = storage .Client ().create_bucket (bucket_name )
36+ bucket = None
37+ while bucket is None or bucket .exists ():
38+ bucket_name = "test-iam-{}" .format (uuid .uuid4 ())
39+ bucket = storage .Client ().bucket (bucket_name )
40+ bucket .create ()
3741 bucket .iam_configuration .uniform_bucket_level_access_enabled = True
3842 bucket .patch ()
3943 yield bucket
Original file line number Diff line number Diff line change 2525
2626@pytest .fixture ()
2727def bucket ():
28- """Creates a test bucket and deletes it upon completion."""
29- client = storage .Client ()
30- bucket_name = "uniform-bucket-level-access-" + str (int (time .time ()))
31- bucket = client .create_bucket (bucket_name )
28+ """Yields a bucket that is deleted after the test completes."""
29+ bucket = None
30+ while bucket is None or bucket .exists ():
31+ bucket_name = "uniform-bucket-level-access-{}" .format (int (time .time ()))
32+ bucket = storage .Client ().bucket (bucket_name )
33+ bucket .create ()
3234 yield bucket
3335 time .sleep (3 )
3436 bucket .delete (force = True )
You can’t perform that action at this time.
0 commit comments