21
21
from test_utils .retry import RetryErrors
22
22
from . import _helpers
23
23
24
+ # Work around https://github.com/googleapis/python-test-utils/issues/36
25
+ if six .PY3 :
26
+ retry_failures = RetryErrors (AssertionError )
27
+ else :
28
+
29
+ def retry_failures (decorated ): # no-op
30
+ return decorated
31
+
24
32
25
33
def test_bucket_create_w_alt_storage_class (storage_client , buckets_to_delete ):
26
34
from google .cloud .storage import constants
@@ -369,13 +377,13 @@ def test_bucket_get_blob_with_user_project(
369
377
assert found .download_as_bytes () == payload
370
378
371
379
372
- @RetryErrors ( AssertionError )
380
+ @retry_failures
373
381
def test_bucket_list_blobs (listable_bucket , listable_filenames ):
374
382
all_blobs = list (listable_bucket .list_blobs ())
375
383
assert sorted (blob .name for blob in all_blobs ) == sorted (listable_filenames )
376
384
377
385
378
- @RetryErrors ( AssertionError )
386
+ @retry_failures
379
387
def test_bucket_list_blobs_w_user_project (
380
388
storage_client , listable_bucket , listable_filenames , user_project ,
381
389
):
@@ -386,7 +394,7 @@ def test_bucket_list_blobs_w_user_project(
386
394
assert sorted (blob .name for blob in all_blobs ) == sorted (listable_filenames )
387
395
388
396
389
- @RetryErrors ( AssertionError )
397
+ @retry_failures
390
398
def test_bucket_list_blobs_paginated (listable_bucket , listable_filenames ):
391
399
truncation_size = 1
392
400
count = len (listable_filenames ) - truncation_size
@@ -408,7 +416,7 @@ def test_bucket_list_blobs_paginated(listable_bucket, listable_filenames):
408
416
assert len (last_blobs ) == truncation_size
409
417
410
418
411
- @RetryErrors ( AssertionError )
419
+ @retry_failures
412
420
def test_bucket_list_blobs_paginated_w_offset (listable_bucket , listable_filenames ):
413
421
truncation_size = 1
414
422
inclusive_start_offset = listable_filenames [1 ]
@@ -439,15 +447,15 @@ def test_bucket_list_blobs_paginated_w_offset(listable_bucket, listable_filename
439
447
assert last_blobs [- 1 ].name == desired_files [- 1 ]
440
448
441
449
442
- @RetryErrors ( AssertionError )
450
+ @retry_failures
443
451
def test_blob_exists_hierarchy (hierarchy_bucket , hierarchy_filenames ):
444
452
for filename in hierarchy_filenames :
445
453
blob = hierarchy_bucket .blob (filename )
446
454
assert blob .exists ()
447
455
448
456
449
- @RetryErrors ( AssertionError )
450
- def test_list_blobs_hierarchy_root_level (hierarchy_bucket , hierarchy_filenames ):
457
+ @retry_failures
458
+ def test_bucket_list_blobs_hierarchy_root_level (hierarchy_bucket , hierarchy_filenames ):
451
459
expected_names = ["file01.txt" ]
452
460
expected_prefixes = set (["parent/" ])
453
461
@@ -460,8 +468,8 @@ def test_list_blobs_hierarchy_root_level(hierarchy_bucket, hierarchy_filenames):
460
468
assert iterator .prefixes == expected_prefixes
461
469
462
470
463
- @RetryErrors ( AssertionError )
464
- def test_list_blobs_hierarchy_first_level (hierarchy_bucket , hierarchy_filenames ):
471
+ @retry_failures
472
+ def test_bucket_list_blobs_hierarchy_first_level (hierarchy_bucket , hierarchy_filenames ):
465
473
expected_names = ["parent/" , "parent/file11.txt" ]
466
474
expected_prefixes = set (["parent/child/" ])
467
475
@@ -474,8 +482,10 @@ def test_list_blobs_hierarchy_first_level(hierarchy_bucket, hierarchy_filenames)
474
482
assert iterator .prefixes == expected_prefixes
475
483
476
484
477
- @RetryErrors (AssertionError )
478
- def test_list_blobs_hierarchy_second_level (hierarchy_bucket , hierarchy_filenames ):
485
+ @retry_failures
486
+ def test_bucket_list_blobs_hierarchy_second_level (
487
+ hierarchy_bucket , hierarchy_filenames
488
+ ):
479
489
expected_names = ["parent/child/file21.txt" , "parent/child/file22.txt" ]
480
490
expected_prefixes = set (["parent/child/grand/" , "parent/child/other/" ])
481
491
@@ -487,8 +497,8 @@ def test_list_blobs_hierarchy_second_level(hierarchy_bucket, hierarchy_filenames
487
497
assert iterator .prefixes == expected_prefixes
488
498
489
499
490
- @RetryErrors ( AssertionError )
491
- def test_list_blobs_hierarchy_third_level (hierarchy_bucket , hierarchy_filenames ):
500
+ @retry_failures
501
+ def test_bucket_list_blobs_hierarchy_third_level (hierarchy_bucket , hierarchy_filenames ):
492
502
# Pseudo-hierarchy can be arbitrarily deep, subject to the limit
493
503
# of 1024 characters in the UTF-8 encoded name:
494
504
# https://cloud.google.com/storage/docs/bucketnaming#objectnames
@@ -505,8 +515,8 @@ def test_list_blobs_hierarchy_third_level(hierarchy_bucket, hierarchy_filenames)
505
515
assert iterator .prefixes == expected_prefixes
506
516
507
517
508
- @RetryErrors ( AssertionError )
509
- def test_list_blobs_hierarchy_w_include_trailing_delimiter (
518
+ @retry_failures
519
+ def test_bucket_list_blobs_hierarchy_w_include_trailing_delimiter (
510
520
hierarchy_bucket , hierarchy_filenames ,
511
521
):
512
522
expected_names = ["file01.txt" , "parent/" ]
0 commit comments