Skip to content

Commit

Permalink
build: treat warnings as errors (#564)
Browse files Browse the repository at this point in the history
* build: treat warnings as errors

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* lint

* add pytest.ini

* add line break

* filter warning which appears only in python 3.7

* filter deprecation warning for grpcio-gcp

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
parthea and gcf-owl-bot[bot] committed Dec 4, 2023
1 parent 42e8b6e commit 46e8789
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
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:phred@example.com"
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:phred@example.com"
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:phred@example.com"
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:cloud-logs@google.com"
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

0 comments on commit 46e8789

Please sign in to comment.