Drop duplicate hacking check of thrid party mock

hacking now provides H216 check[1] to detect usage of third party mock
so the same check can be dropped from the local plugin.

[1] b921c4de513c9cc624d6ecf68e4f4493e6e72c0d

Change-Id: I0c6f86d1d47554f0127fc6a122f94ec8586964ec
This commit is contained in:
Takashi Kajinami
2024-11-23 06:04:18 +09:00
parent 814e76dc53
commit dde7b2003c
4 changed files with 0 additions and 25 deletions

View File

@@ -19,7 +19,6 @@ Manila Specific Commandments
with a sequence of key-value pairs.
- [M337] Ensure to not use xrange().
- [M338] Ensure to not use LOG.warn().
- [M339] Ensure 'mock' is not imported/used. Use 'unittest.mock' instead.
- [M354] Use oslo_utils.uuidutils to generate UUID instead of uuid4().
- [M359] Validate that log messages are not translated.

View File

@@ -51,8 +51,6 @@ dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
assert_True = re.compile(r".*assertEqual\(True, .*\)")
no_log_warn = re.compile(r"\s*LOG.warn\(.*")
third_party_mock = re.compile(r"^import.mock")
from_third_party_mock = re.compile(r"^from.mock.import")
class BaseASTChecker(ast.NodeVisitor):
@@ -284,14 +282,3 @@ def no_log_warn_check(logical_line):
msg = ("M338: LOG.warn is deprecated, use LOG.warning.")
if re.match(no_log_warn, logical_line):
yield (0, msg)
@core.flake8ext
def no_third_party_mock(logical_line):
# We should only use unittest.mock, not the third party mock library that
# was needed for py2 support.
if (re.match(third_party_mock, logical_line) or
re.match(from_third_party_mock, logical_line)):
msg = ('M339: Unit tests should use the standard library "mock" '
'module, not the third party mock library.')
yield (0, msg)

View File

@@ -247,16 +247,6 @@ class HackingTestCase(test.TestCase):
"""
self._assert_has_no_errors(code, checks.check_uuid4)
@ddt.unpack
@ddt.data(
(1, 'import mock'),
(0, 'from unittest import mock'),
(1, 'from mock import patch'),
(0, 'from unittest.mock import patch'))
def test_no_third_party_mock(self, err_count, line):
self.assertEqual(err_count,
len(list(checks.no_third_party_mock(line))))
def test_no_log_warn_check(self):
self.assertEqual(0, len(list(checks.no_log_warn_check(
"LOG.warning('This should not trigger LOG.warn "

View File

@@ -169,7 +169,6 @@ extension =
M336 = checks:dict_constructor_with_list_copy
M337 = checks:no_xrange
M338 = checks:no_log_warn_check
M339 = checks:no_third_party_mock
M354 = checks:check_uuid4
M359 = checks:no_translate_logs
paths = ./manila/tests/hacking