Merge "Replace LOG.warn"
This commit is contained in:
@@ -3,3 +3,4 @@ Trove Library Specific Commandments
|
||||
|
||||
- [T103] Exception messages should be translated
|
||||
- [T105] Validate no LOG translations
|
||||
- [T106] LOG.warn() is not allowed. Use LOG.warning()
|
||||
|
||||
1
tox.ini
1
tox.ini
@@ -77,6 +77,7 @@ import_exceptions = trove.common.i18n
|
||||
extension =
|
||||
# T103= checks:check_raised_localized_exceptions
|
||||
T105 = checks:no_translate_logs
|
||||
T106 = checks:no_log_warn
|
||||
paths = ./trove/hacking
|
||||
|
||||
[testenv:api-ref]
|
||||
|
||||
@@ -76,9 +76,9 @@ def main():
|
||||
try:
|
||||
guestagent_utils.disable_user_defined_port()
|
||||
except Exception as e:
|
||||
LOG.warn("failed to down the user defined port when "
|
||||
"network_isolation is set to true due to: %s."
|
||||
"pass...", str(e))
|
||||
LOG.warning("failed to down the user defined port when "
|
||||
"network_isolation is set to true due to: %s."
|
||||
"pass...", str(e))
|
||||
pass
|
||||
|
||||
# Create user and group for running docker container.
|
||||
|
||||
@@ -75,3 +75,15 @@ def no_translate_logs(logical_line, filename, noqa):
|
||||
msg = "T105: Log message shouldn't be translated."
|
||||
if _translated_log.match(logical_line):
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_log_warn(logical_line):
|
||||
"""Disallow 'LOG.warn('
|
||||
|
||||
https://bugs.launchpad.net/tempest/+bug/1508442
|
||||
|
||||
T106
|
||||
"""
|
||||
if logical_line.startswith('LOG.warn('):
|
||||
yield (0, 'T106 Use LOG.warning() rather than LOG.warn()')
|
||||
|
||||
@@ -70,3 +70,9 @@ class HackingTestCase(trove_testtools.TestCase):
|
||||
f = tc.check_raised_localized_exceptions
|
||||
self.assertLinePasses(f, "raise KeyError('Error text')",
|
||||
'neutron_lib/tests/unit/mytest.py')
|
||||
|
||||
def test_no_log_warn(self):
|
||||
self.assertEqual(1, len(list(tc.no_log_warn(
|
||||
"LOG.warn(\"LOG.warn is deprecated\")"))))
|
||||
self.assertEqual(0, len(list(tc.no_log_warn(
|
||||
"LOG.warning(\"LOG.warn is deprecated\")"))))
|
||||
|
||||
Reference in New Issue
Block a user