From c4471758e1efee0e3599b08969449b2ce71bd1b4 Mon Sep 17 00:00:00 2001 From: Kevin Zheng <147537668+gkevinzheng@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:39:57 -0500 Subject: [PATCH] fix: Use warning instead of warn in system tests to avoid DeprecationWarning (#821) * fix: Use warning instead of warn in system tests to avoid DeprecationWarning * Removed ignore like from pytest.ini --- pytest.ini | 2 -- tests/system/test_system.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pytest.ini b/pytest.ini index 994e939c..8bc54e71 100644 --- a/pytest.ini +++ b/pytest.ini @@ -17,7 +17,5 @@ filterwarnings = ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning:google.cloud.logging_v2.handlers.transports ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning:tests.unit.test__http ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning:tests.unit.test_entries - # Remove once https://github.com/googleapis/python-logging/issues/820 is fixed - ignore:.*warn.*is deprecated, use.*warning.*instead:DeprecationWarning # Remove once a version of grpcio newer than 1.59.3 is released to PyPI ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning:grpc._channel diff --git a/tests/system/test_system.py b/tests/system/test_system.py index ec67a99d..821a938d 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -605,7 +605,7 @@ def test_handlers_w_extras(self): "resource": Resource(type="cloudiot_device", labels={}), "labels": {"test-label": "manual"}, } - cloud_logger.warn(LOG_MESSAGE, extra=extra) + cloud_logger.warning(LOG_MESSAGE, extra=extra) entries = _list_entries(logger) self.assertEqual(len(entries), 1) @@ -634,7 +634,7 @@ def test_handlers_w_json_fields(self): cloud_logger = logging.getLogger(LOGGER_NAME) cloud_logger.addHandler(handler) extra = {"json_fields": {"hello": "world", "two": 2}} - cloud_logger.warn(LOG_MESSAGE, extra=extra) + cloud_logger.warning(LOG_MESSAGE, extra=extra) entries = _list_entries(logger) self.assertEqual(len(entries), 1)