Add test for no_translate_debug_logs hacking check

Adds a test for this hacking check. Also update the code (G319).

Change-Id: I91996b94166f0e69ee4f5fc0b704118d59bfe841
This commit is contained in:
Chris Buccella 2014-06-10 02:53:40 +00:00
parent 3994eeb862
commit a8151f1ba6
2 changed files with 11 additions and 1 deletions

View File

@ -88,7 +88,7 @@ def no_translate_debug_logs(logical_line, filename):
if max([name in filename for name in dirs]):
if logical_line.startswith("LOG.debug(_("):
yield(0, "N319: Don't translate debug level logs")
yield(0, "G319: Don't translate debug level logs")
def factory(register):

View File

@ -41,3 +41,13 @@ class HackingTestCase(utils.BaseTestCase):
self.assertEqual(
0, len(list(checks.assert_equal_none("self.assertIsNone()"))))
def test_no_translate_debug_logs(self):
self.assertEqual(1, len(list(checks.no_translate_debug_logs(
"LOG.debug(_('foo'))", "glance/store/foo.py"))))
self.assertEqual(0, len(list(checks.no_translate_debug_logs(
"LOG.debug('foo')", "glance/store/foo.py"))))
self.assertEqual(0, len(list(checks.no_translate_debug_logs(
"LOG.info(_('foo'))", "glance/store/foo.py"))))