Drop duplicate hacking check

Usage of assertTrue(isinstance(a, b)) is already checked by
the built-in H211 check which is enabled by default.

Change-Id: Ib72a4055212d125718bb5a096fb602ddb2878406
This commit is contained in:
Takashi Kajinami 2024-11-27 11:32:09 +09:00
parent 95a7cac499
commit 3a0f7bcb97
4 changed files with 0 additions and 36 deletions

View File

@ -19,7 +19,6 @@ Below you can find a list of checks specific to this repository.
- [N329] Use assertCountEqual() instead of assertItemsEqual()
- [N330] Use assertEqual(*empty*, observed) instead of
assertEqual(observed, *empty*)
- [N331] Detect wrong usage with assertTrue(isinstance()).
- [N332] Use assertEqual(expected_http_code, observed_http_code) instead of
assertEqual(observed_http_code, expected_http_code).
- [N340] Check usage of <module>.i18n (and neutron.i18n)

View File

@ -119,17 +119,6 @@ def check_assertempty(logical_line, filename):
yield (0, msg)
@core.flake8ext
def check_assertisinstance(logical_line, filename):
"""N331 - Enforce using assertIsInstance."""
if 'neutron/tests/' in filename:
if re.search(r"assertTrue\(\s*isinstance\(\s*[^,]*,\s*[^,]*\)\)",
logical_line):
msg = ("N331: Use assertIsInstance(observed, type) instead "
"of assertTrue(isinstance(observed, type))")
yield (0, msg)
@core.flake8ext
def check_assertequal_for_httpcode(logical_line, filename):
"""N332 - Enforce correct ordering for httpcode in assertEqual."""

View File

@ -162,29 +162,6 @@ class HackingTestCase(base.BaseTestCase):
pass_code2 % ec,
"neutron/tests/test_assert.py"))))
def test_assertisinstance(self):
fail_code = """
self.assertTrue(isinstance(observed, ANY_TYPE))
"""
pass_code1 = """
self.assertEqual(ANY_TYPE, type(observed))
"""
pass_code2 = """
self.assertIsInstance(observed, ANY_TYPE)
"""
self.assertEqual(
1, len(list(
checks.check_assertisinstance(
fail_code, "neutron/tests/test_assert.py"))))
self.assertEqual(
0, len(list(
checks.check_assertisinstance(
pass_code1, "neutron/tests/test_assert.py"))))
self.assertEqual(
0, len(list(
checks.check_assertisinstance(
pass_code2, "neutron/tests/test_assert.py"))))
def test_assertequal_for_httpcode(self):
fail_code = """
self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code)

View File

@ -250,7 +250,6 @@ extension =
N328 = neutron.hacking.checks:check_asserttruefalse
N329 = neutron.hacking.checks:check_assertitemsequal
N330 = neutron.hacking.checks:check_assertempty
N331 = neutron.hacking.checks:check_assertisinstance
N332 = neutron.hacking.checks:check_assertequal_for_httpcode
N340 = neutron.hacking.checks:check_oslo_i18n_wrapper
N341 = neutron.hacking.checks:check_builtins_gettext