Skip to content

Commit

Permalink
resolve warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Dec 3, 2023
1 parent 8bec8bd commit c767140
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ filterwarnings =
ignore:.*is using a pure python implementation:RuntimeWarning
# Remove once https://github.com/googleapis/python-storage/issues/1194 is fixed
ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning
# Remove once https://github.com/dateutil/dateutil/issues/1314 is fixed
# dateutil is a dependency of pandas
ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning:dateutil.tz.tz
# Remove once https://github.com/googleapis/python-storage/issues/1195 is fixed
Expand Down
11 changes: 8 additions & 3 deletions tests/system/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import tempfile
import uuid
import warnings

import pytest
import mock
Expand Down Expand Up @@ -862,7 +861,10 @@ def test_blob_compose_w_generation_match_list(shared_bucket, blobs_to_delete):
to_append.upload_from_string(payload_to_append)
blobs_to_delete.append(to_append)

with warnings.catch_warnings(record=True) as log:
with pytest.warns(
DeprecationWarning,
match="'if_generation_match: type list' is deprecated and supported for backwards-compatability reasons only",
) as log:
with pytest.raises(exceptions.PreconditionFailed):
original.compose(
[original, to_append],
Expand All @@ -871,7 +873,10 @@ def test_blob_compose_w_generation_match_list(shared_bucket, blobs_to_delete):
)
assert len(log) == 2

with warnings.catch_warnings(record=True) as log:
with pytest.warns(
DeprecationWarning,
match="'if_generation_match: type list' is deprecated and supported for backwards-compatability reasons only",
) as log:
original.compose(
[original, to_append],
if_generation_match=[original.generation, to_append.generation],
Expand Down
52 changes: 36 additions & 16 deletions tests/system/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ def test_bucket_get_set_iam_policy(

def test_bucket_crud_w_requester_pays(storage_client, buckets_to_delete, user_project):
bucket_name = _helpers.unique_name("w-requester-pays")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name
assert created.requester_pays
Expand Down Expand Up @@ -248,10 +252,14 @@ def test_bucket_acls_iam_w_user_project(
storage_client, buckets_to_delete, user_project
):
bucket_name = _helpers.unique_name("acl-w-user-project")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name,
requester_pays=True,
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name,
requester_pays=True,
)
buckets_to_delete.append(created)

with_user_project = storage_client.bucket(bucket_name, user_project=user_project)
Expand Down Expand Up @@ -354,9 +362,13 @@ def test_bucket_copy_blob_w_user_project(
):
payload = b"DEADBEEF"
bucket_name = _helpers.unique_name("copy-w-requester-pays")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name
assert created.requester_pays
Expand Down Expand Up @@ -410,9 +422,13 @@ def test_bucket_copy_blob_w_metageneration_match(
):
payload = b"DEADBEEF"
bucket_name = _helpers.unique_name("generation-match")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated.",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name

Expand Down Expand Up @@ -442,9 +458,13 @@ def test_bucket_get_blob_with_user_project(
blob_name = "blob-name"
payload = b"DEADBEEF"
bucket_name = _helpers.unique_name("w-requester-pays")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name
assert created.requester_pays
Expand Down

0 comments on commit c767140

Please sign in to comment.