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: I43e2269d4b1c425119c86919eb869941d621c6de
This commit is contained in:
@@ -26,6 +26,7 @@ Tempest Specific Commandments
|
|||||||
- [T116] Unsupported 'message' Exception attribute in PY3
|
- [T116] Unsupported 'message' Exception attribute in PY3
|
||||||
- [T117] Check negative tests have ``@decorators.attr(type=['negative'])``
|
- [T117] Check negative tests have ``@decorators.attr(type=['negative'])``
|
||||||
applied.
|
applied.
|
||||||
|
- [T118] LOG.warn is deprecated. Enforce use of LOG.warning.
|
||||||
|
|
||||||
It is recommended to use ``tox -eautopep8`` before submitting a patch.
|
It is recommended to use ``tox -eautopep8`` before submitting a patch.
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ def verify_glance_api_versions(os, update):
|
|||||||
msg = ('Glance is available in the catalog, but no known version, '
|
msg = ('Glance is available in the catalog, but no known version, '
|
||||||
'(v1.x or v2.x) of Glance could be found, so Glance should '
|
'(v1.x or v2.x) of Glance could be found, so Glance should '
|
||||||
'be configured as not available')
|
'be configured as not available')
|
||||||
LOG.warn(msg)
|
LOG.warning(msg)
|
||||||
print_and_or_update('glance', 'service-available', False, update)
|
print_and_or_update('glance', 'service-available', False, update)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -318,3 +318,16 @@ def negative_test_attribute_always_applied_to_negative_tests(physical_line,
|
|||||||
" to all negative API tests"
|
" to all negative API tests"
|
||||||
)
|
)
|
||||||
_HAVE_NEGATIVE_DECORATOR = False
|
_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)
|
||||||
|
|||||||
@@ -240,3 +240,9 @@ class HackingTestCase(base.TestCase):
|
|||||||
with_other_decorators=True,
|
with_other_decorators=True,
|
||||||
with_negative_decorator=False,
|
with_negative_decorator=False,
|
||||||
expected_success=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")')))
|
||||||
|
|||||||
1
tox.ini
1
tox.ini
@@ -370,6 +370,7 @@ extension =
|
|||||||
T115 = checks:dont_put_admin_tests_on_nonadmin_path
|
T115 = checks:dont_put_admin_tests_on_nonadmin_path
|
||||||
T116 = checks:unsupported_exception_attribute_PY3
|
T116 = checks:unsupported_exception_attribute_PY3
|
||||||
T117 = checks:negative_test_attribute_always_applied_to_negative_tests
|
T117 = checks:negative_test_attribute_always_applied_to_negative_tests
|
||||||
|
T118 = checks:no_log_warn
|
||||||
paths =
|
paths =
|
||||||
./tempest/hacking
|
./tempest/hacking
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user