From 3d585b7d4c31a44f81859acb5522b707257b5117 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 29 Nov 2021 15:36:17 +0900 Subject: [PATCH] Use LOG.warning instead of deprecated LOG.warn The LOG.warn method is deprecated[1] and the LOG.warning method should be used instead. [1] https://docs.python.org/3/library/logging.html#logging.warning Change-Id: If352bbb14a1a44fb2229e633d15e1bf1099fa425 --- oslo_utils/netutils.py | 2 +- oslo_utils/tests/test_netutils.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/oslo_utils/netutils.py b/oslo_utils/netutils.py index 3d8a2a2c..19f54e73 100644 --- a/oslo_utils/netutils.py +++ b/oslo_utils/netutils.py @@ -112,7 +112,7 @@ def is_valid_ipv4(address, strict=None): return True else: if netaddr.valid_ipv4(address): - LOG.warn( + LOG.warning( 'Converting in non strict mode is deprecated. ' 'You should pass strict=False if you want to ' 'preserve legacy behavior') diff --git a/oslo_utils/tests/test_netutils.py b/oslo_utils/tests/test_netutils.py index 93fedf39..087522cb 100644 --- a/oslo_utils/tests/test_netutils.py +++ b/oslo_utils/tests/test_netutils.py @@ -166,16 +166,16 @@ class NetworkUtilsTest(test_base.BaseTestCase): self.assertFalse(netutils.is_valid_ipv4('')) self.assertTrue(netutils.is_valid_ipv4('10')) - mock_log.warn.assert_called_with(expected_log) + mock_log.warning.assert_called_with(expected_log) mock_log.reset_mock() self.assertTrue(netutils.is_valid_ipv4('10.10')) - mock_log.warn.assert_called_with(expected_log) + mock_log.warning.assert_called_with(expected_log) mock_log.reset_mock() self.assertTrue(netutils.is_valid_ipv4('10.10.10')) - mock_log.warn.assert_called_with(expected_log) + mock_log.warning.assert_called_with(expected_log) mock_log.reset_mock() self.assertTrue(netutils.is_valid_ipv4('10.10.10.10')) - mock_log.warn.assert_not_called() + mock_log.warning.assert_not_called() mock_log.reset_mock() self.assertFalse( netutils.is_valid_ipv4('10', strict=True) @@ -186,7 +186,7 @@ class NetworkUtilsTest(test_base.BaseTestCase): self.assertFalse( netutils.is_valid_ipv4('10.10.10', strict=True) ) - mock_log.warn.assert_not_called() + mock_log.warning.assert_not_called() mock_log.reset_mock() self.assertTrue( netutils.is_valid_ipv4('10', strict=False) @@ -197,7 +197,7 @@ class NetworkUtilsTest(test_base.BaseTestCase): self.assertTrue( netutils.is_valid_ipv4('10.10.10', strict=False) ) - mock_log.warn.assert_not_called() + mock_log.warning.assert_not_called() mock_log.reset_mock() def test_is_valid_ipv6(self):