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
This commit is contained in:
Takashi Kajinami 2021-11-29 15:36:17 +09:00
parent 3b5eebdc1c
commit 3d585b7d4c
2 changed files with 7 additions and 7 deletions

View File

@ -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')

View File

@ -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):