diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..e7de29bb4 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,25 @@ +[pytest] +filterwarnings = + # treat all warnings as errors + error + # Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed + ignore:.*custom tp_new.*in Python 3.14:DeprecationWarning + # Remove once Release PR https://github.com/googleapis/python-api-common-protos/pull/191 is merged + ignore:.*pkg_resources.declare_namespace:DeprecationWarning + ignore:.*pkg_resources is deprecated as an API:DeprecationWarning + # Remove once https://github.com/googleapis/python-storage/issues/1193 is fixed + ignore:.*unclosed:ResourceWarning + # Remove once release PR https://github.com/googleapis/proto-plus-python/pull/391 is merged + ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning:proto.datetime_helpers + # Remove once https://github.com/googleapis/python-crc32c/issues/178 is fixed + 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 + ignore:Blob.download_as_string\(\) is deprecated and will be removed in future. Use Blob.download_as_bytes\(\) instead:PendingDeprecationWarning + ignore:Assignment to.*is deprecated, as it is only valid before the bucket is created. Instead, pass the location to.*Bucket.create:DeprecationWarning + # Remove after support for Python 3.7 is dropped + ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning diff --git a/tests/system/test_blob.py b/tests/system/test_blob.py index a35c047b1..a3da7dea4 100644 --- a/tests/system/test_blob.py +++ b/tests/system/test_blob.py @@ -18,7 +18,6 @@ import os import tempfile import uuid -import warnings import pytest import mock @@ -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], @@ -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], diff --git a/tests/system/test_bucket.py b/tests/system/test_bucket.py index 9b2fcd614..2f67f3d87 100644 --- a/tests/system/test_bucket.py +++ b/tests/system/test_bucket.py @@ -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 @@ -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) @@ -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 @@ -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 @@ -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