diff --git a/HACKING.rst b/HACKING.rst index c2346e3c244..bd1e069c366 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -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 .i18n (and neutron.i18n) diff --git a/neutron/hacking/checks.py b/neutron/hacking/checks.py index 66dd8addf0b..a066b8e7988 100644 --- a/neutron/hacking/checks.py +++ b/neutron/hacking/checks.py @@ -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.""" diff --git a/neutron/tests/unit/hacking/test_checks.py b/neutron/tests/unit/hacking/test_checks.py index efe0741d971..cec4489b1e9 100644 --- a/neutron/tests/unit/hacking/test_checks.py +++ b/neutron/tests/unit/hacking/test_checks.py @@ -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) diff --git a/tox.ini b/tox.ini index 4f6df4f5764..443097ff662 100644 --- a/tox.ini +++ b/tox.ini @@ -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