Thanks to visit codestin.com
Credit goes to github.com

Skip to content

build: treat warnings as errors #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[pytest]
filterwarnings =
# treat all warnings as errors
error
# Remove once https://github.com/pytest-dev/pytest-cov/issues/621 is fixed
ignore:.*The --rsyncdir command line argument and rsyncdirs config variable are deprecated:DeprecationWarning
# Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed
ignore:.*custom tp_new.*in Python 3.14:DeprecationWarning
# Remove once support for python 3.7 is dropped
# This warning only appears when using python 3.7
ignore:.*Using or importing the ABCs from.*collections:DeprecationWarning
# Remove once support for grpcio-gcp is deprecated
# See https://github.com/googleapis/python-api-core/blob/42e8b6e6f426cab749b34906529e8aaf3f133d75/google/api_core/grpc_helpers.py#L39-L45
ignore:.*Support for grpcio-gcp is deprecated:DeprecationWarning
# Remove once https://github.com/googleapis/python-api-common-protos/pull/187/files is merged
ignore:.*pkg_resources.declare_namespace:DeprecationWarning
ignore:.*pkg_resources is deprecated as an API:DeprecationWarning
# 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/grpc/grpc/issues/35086 is fixed
ignore:There is no current event loop:DeprecationWarning
20 changes: 12 additions & 8 deletions tests/unit/test_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,15 @@ def test_owners_getter(self):
assert policy.owners == expected

def test_owners_setter(self):
import warnings
from google.api_core.iam import OWNER_ROLE

MEMBER = "user:[email protected]"
expected = set([MEMBER])
policy = self._make_one()

with warnings.catch_warnings(record=True) as warned:
with pytest.warns(
DeprecationWarning, match="Assigning to 'owners' is deprecated."
) as warned:
policy.owners = [MEMBER]

(warning,) = warned
Expand All @@ -191,14 +192,15 @@ def test_editors_getter(self):
assert policy.editors == expected

def test_editors_setter(self):
import warnings
from google.api_core.iam import EDITOR_ROLE

MEMBER = "user:[email protected]"
expected = set([MEMBER])
policy = self._make_one()

with warnings.catch_warnings(record=True) as warned:
with pytest.warns(
DeprecationWarning, match="Assigning to 'editors' is deprecated."
) as warned:
policy.editors = [MEMBER]

(warning,) = warned
Expand All @@ -215,14 +217,15 @@ def test_viewers_getter(self):
assert policy.viewers == expected

def test_viewers_setter(self):
import warnings
from google.api_core.iam import VIEWER_ROLE

MEMBER = "user:[email protected]"
expected = set([MEMBER])
policy = self._make_one()

with warnings.catch_warnings(record=True) as warned:
with pytest.warns(
DeprecationWarning, match="Assigning to 'viewers' is deprecated."
) as warned:
policy.viewers = [MEMBER]

(warning,) = warned
Expand Down Expand Up @@ -337,12 +340,13 @@ def test_to_api_repr_binding_wo_members(self):
assert policy.to_api_repr() == {}

def test_to_api_repr_binding_w_duplicates(self):
import warnings
from google.api_core.iam import OWNER_ROLE

OWNER = "group:[email protected]"
policy = self._make_one()
with warnings.catch_warnings(record=True):
with pytest.warns(
DeprecationWarning, match="Assigning to 'owners' is deprecated."
):
policy.owners = [OWNER, OWNER]
assert policy.to_api_repr() == {
"bindings": [{"role": OWNER_ROLE, "members": [OWNER]}]
Expand Down