Merge "Remove local Hacking for M318"

This commit is contained in:
Jenkins 2017-07-27 13:36:40 +00:00 committed by Gerrit Code Review
commit 9f04fc52ed
3 changed files with 0 additions and 30 deletions

View File

@ -7,8 +7,6 @@ Mistral Specific Commandments
-----------------------------
- [M001] Use LOG.warning(). LOG.warn() is deprecated.
- [M318] Change assertEqual(A, None) or assertEqual(None, A) by optimal assert
like assertIsNone(A)
- [M319] Enforce use of assertTrue/assertFalse
- [M320] Enforce use of assertIs/assertIsNot
- [M327] Do not use xrange(). xrange() is not compatible with Python 3. Use

View File

@ -30,28 +30,11 @@ import six
oslo_namespace_imports_dot = re.compile(r"import[\s]+oslo[.][^\s]+")
oslo_namespace_imports_from_dot = re.compile(r"from[\s]+oslo[.]")
oslo_namespace_imports_from_root = re.compile(r"from[\s]+oslo[\s]+import[\s]+")
assert_equal_end_with_none_re = re.compile(
r"(.)*assertEqual\((\w|\.|\'|\"|\[|\])+, None\)")
assert_equal_start_with_none_re = re.compile(
r"(.)*assertEqual\(None, (\w|\.|\'|\"|\[|\])+\)")
log_string_interpolation = re.compile(r".*LOG\.(?:error|warn|warning|info"
r"|critical|exception|debug)"
r"\([^,]*%[^,]*[,)]")
def assert_equal_none(logical_line):
"""Check for assertEqual(A, None) or assertEqual(None, A) sentences
M318
"""
msg = ("M318: assertEqual(A, None) or assertEqual(None, A) "
"sentences not allowed. Use assertIsNone instead.")
res = (assert_equal_start_with_none_re.match(logical_line) or
assert_equal_end_with_none_re.match(logical_line))
if res:
yield (0, msg)
def no_assert_equal_true_false(logical_line):
"""Check for assertTrue/assertFalse sentences
@ -306,7 +289,6 @@ class CheckForLoggingIssues(BaseASTChecker):
def factory(register):
register(assert_equal_none)
register(no_assert_equal_true_false)
register(no_assert_true_false_is_not)
register(check_oslo_namespace_imports)

View File

@ -59,16 +59,6 @@ class BaseLoggingCheckTest(base.BaseTest):
def _assert_has_no_errors(self, code, checker, filename=None):
self._assert_has_errors(code, checker, filename=filename)
def test_assert_equal_none(self):
self.assertEqual(len(list(checks.assert_equal_none(
"self.assertEqual(A, None)"))), 1)
self.assertEqual(len(list(checks.assert_equal_none(
"self.assertEqual(None, A)"))), 1)
self.assertEqual(
len(list(checks.assert_equal_none("self.assertIsNone()"))), 0)
def test_no_assert_equal_true_false(self):
code = """
self.assertEqual(context_is_admin, True)