Add a testcase to test whether using log.warn
Change-Id: I38ff5865991ceab80f98b4c10c40cffaae5a6946
This commit is contained in:
parent
a9e0ba7d73
commit
2a4b99bf89
@ -21,3 +21,4 @@ Zun Specific Commandments
|
|||||||
with a sequence of key-value pairs.
|
with a sequence of key-value pairs.
|
||||||
- [Z338] Use assertIn/NotIn(A, B) rather than assertEqual(A in B, True/False).
|
- [Z338] Use assertIn/NotIn(A, B) rather than assertEqual(A in B, True/False).
|
||||||
- [Z339] Don't use xrange()
|
- [Z339] Don't use xrange()
|
||||||
|
- [Z352] LOG.warn is deprecated. Enforce use of LOG.warning.
|
||||||
|
@ -144,6 +144,20 @@ def dict_constructor_with_list_copy(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
def no_log_warn(logical_line):
|
||||||
|
"""Disallow 'LOG.warn('
|
||||||
|
|
||||||
|
Deprecated LOG.warn(), instead use LOG.warning
|
||||||
|
https://review.openstack.org/#/c/412768/
|
||||||
|
|
||||||
|
Z352
|
||||||
|
"""
|
||||||
|
|
||||||
|
msg = ("Z352: LOG.warn is deprecated, please use LOG.warning!")
|
||||||
|
if "LOG.warn(" in logical_line:
|
||||||
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
def factory(register):
|
def factory(register):
|
||||||
register(no_mutable_default_args)
|
register(no_mutable_default_args)
|
||||||
register(assert_equal_none)
|
register(assert_equal_none)
|
||||||
@ -154,3 +168,4 @@ def factory(register):
|
|||||||
register(use_timeutils_utcnow)
|
register(use_timeutils_utcnow)
|
||||||
register(dict_constructor_with_list_copy)
|
register(dict_constructor_with_list_copy)
|
||||||
register(no_xrange)
|
register(no_xrange)
|
||||||
|
register(no_log_warn)
|
||||||
|
@ -232,3 +232,16 @@ class HackingTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
|
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
|
||||||
" self._render_dict(xml, data_el, data.__dict__)"))))
|
" self._render_dict(xml, data_el, data.__dict__)"))))
|
||||||
|
|
||||||
|
def test_no_log_warn(self):
|
||||||
|
errors = [(1, 0, "Z352")]
|
||||||
|
check = checks.no_log_warn
|
||||||
|
code = """
|
||||||
|
LOG.warn("LOG.warn is deprecated")
|
||||||
|
"""
|
||||||
|
self._assert_has_errors(code, check, errors)
|
||||||
|
|
||||||
|
code = """
|
||||||
|
LOG.warning("LOG.warn is deprecated")
|
||||||
|
"""
|
||||||
|
self._assert_has_no_errors(code, check)
|
||||||
|
Loading…
Reference in New Issue
Block a user