From a3a3f5330ee2485e927c6f8cd926c097cca85305 Mon Sep 17 00:00:00 2001 From: junboli Date: Thu, 27 Jul 2017 08:27:29 +0800 Subject: [PATCH] Remove local Hacking for M318 Since we have added H203 in tox.ini [1], the local Hacking for M318 can be removed. [1] https://review.openstack.org/#/c/484089/ Change-Id: Ieb652a41b77effdd8a67ea619ab592b1b065aec5 --- HACKING.rst | 2 -- mistral/hacking/checks.py | 18 ------------------ mistral/tests/unit/hacking/test_checks.py | 10 ---------- 3 files changed, 30 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index 0151246cd..e1bec9e51 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -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 diff --git a/mistral/hacking/checks.py b/mistral/hacking/checks.py index e9d5a1e65..0e0cbfc0c 100644 --- a/mistral/hacking/checks.py +++ b/mistral/hacking/checks.py @@ -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) diff --git a/mistral/tests/unit/hacking/test_checks.py b/mistral/tests/unit/hacking/test_checks.py index 6d910c457..dbf15ea44 100644 --- a/mistral/tests/unit/hacking/test_checks.py +++ b/mistral/tests/unit/hacking/test_checks.py @@ -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)