Merge "Use LOG.warning instead of deprecated LOG.warn"
diff --git a/HACKING.rst b/HACKING.rst
index 95bcbb5..dc28e4e 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -26,6 +26,7 @@
- [T116] Unsupported 'message' Exception attribute in PY3
- [T117] Check negative tests have ``@decorators.attr(type=['negative'])``
applied.
+- [T118] LOG.warn is deprecated. Enforce use of LOG.warning.
It is recommended to use ``tox -eautopep8`` before submitting a patch.
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 0db1ab1..421afd3 100644
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -130,7 +130,7 @@
msg = ('Glance is available in the catalog, but no known version, '
'(v1.x or v2.x) of Glance could be found, so Glance should '
'be configured as not available')
- LOG.warn(msg)
+ LOG.warning(msg)
print_and_or_update('glance', 'service-available', False, update)
return
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index c1e6b2d..1c9c55b 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -318,3 +318,16 @@
" to all negative API tests"
)
_HAVE_NEGATIVE_DECORATOR = False
+
+
+@core.flake8ext
+def no_log_warn(logical_line):
+ """Disallow 'LOG.warn('
+
+ Use LOG.warning() instead of Deprecated LOG.warn().
+ https://docs.python.org/3/library/logging.html#logging.warning
+ """
+
+ msg = ("T118: LOG.warn is deprecated, please use LOG.warning!")
+ if "LOG.warn(" in logical_line:
+ yield (0, msg)
diff --git a/tempest/tests/test_hacking.py b/tempest/tests/test_hacking.py
index 7c31185..464e66a 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -240,3 +240,9 @@
with_other_decorators=True,
with_negative_decorator=False,
expected_success=False)
+
+ def test_no_log_warn(self):
+ self.assertFalse(list(checks.no_log_warn(
+ 'LOG.warning("LOG.warn is deprecated")')))
+ self.assertTrue(list(checks.no_log_warn(
+ 'LOG.warn("LOG.warn is deprecated")')))
diff --git a/tox.ini b/tox.ini
index 18f2aa6..b07fdaf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -369,6 +369,7 @@
T115 = checks:dont_put_admin_tests_on_nonadmin_path
T116 = checks:unsupported_exception_attribute_PY3
T117 = checks:negative_test_attribute_always_applied_to_negative_tests
+ T118 = checks:no_log_warn
paths =
./tempest/hacking