From ee6576c4eb7bf031d6728d57db4a649d5c39243f Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Fri, 10 Jul 2015 10:25:50 -0400 Subject: [PATCH] Remove hacking check N327 With mock 1.1.0+, mock will fail when nonexistent methods are called, so this check is no longer necessary. Related-Bug: #1473454 Change-Id: I9cb8b4a5eab78e51728aa8f83668f5979c0b9be1 --- HACKING.rst | 1 - cinder/hacking/checks.py | 12 ------------ cinder/tests/unit/test_hacking.py | 10 ---------- 3 files changed, 23 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index f0cdbad9b..b0e412311 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -12,7 +12,6 @@ Cinder Specific Commandments - [N322] Ensure default arguments are not mutable. - [N323] Add check for explicit import of _() to ensure proper translation. - [N325] str() and unicode() cannot be used on an exception. Remove or use six.text_type(). -- [N327] assert_called_once is not a valid Mock method. - [N328] LOG.info messages require translations `_LI()`. - [N329] LOG.exception and LOG.error messages require translations `_LE()`. - [N330] LOG.warning messages require translations `_LW()`. diff --git a/cinder/hacking/checks.py b/cinder/hacking/checks.py index bb33e445e..e130b077c 100644 --- a/cinder/hacking/checks.py +++ b/cinder/hacking/checks.py @@ -200,17 +200,6 @@ class CheckForStrUnicodeExc(BaseASTChecker): super(CheckForStrUnicodeExc, self).generic_visit(node) -def check_assert_called_once(logical_line, filename): - msg = ("N327: assert_called_once is a no-op. please use assert_called_" - "once_with to test with explicit parameters or an assertEqual with" - " call_count.") - - if 'cinder/tests/functional' or 'cinder/tests/unit' in filename: - pos = logical_line.find('.assert_called_once(') - if pos != -1: - yield (pos, msg) - - def validate_log_translations(logical_line, filename): # Translations are not required in the test directory. # This will not catch all instances of violations, just direct @@ -324,7 +313,6 @@ def factory(register): register(no_mutable_default_args) register(check_explicit_underscore_import) register(CheckForStrUnicodeExc) - register(check_assert_called_once) register(check_oslo_namespace_imports) register(check_datetime_now) register(check_timeutils_strtime) diff --git a/cinder/tests/unit/test_hacking.py b/cinder/tests/unit/test_hacking.py index 4f0cd8894..62214480b 100644 --- a/cinder/tests/unit/test_hacking.py +++ b/cinder/tests/unit/test_hacking.py @@ -221,16 +221,6 @@ class HackingTestCase(test.TestCase): self.assertEqual(1, len(list(checks.no_mutable_default_args( "def foo (bar={}):")))) - def test_check_assert_called_once(self): - self.assertEqual(0, len(list(checks.check_assert_called_once( - ".assert_called_with(", "cinder/tests/unit/test1.py")))) - self.assertEqual(0, len(list(checks.check_assert_called_once( - ".assert_called_with(", "cinder/blah.py")))) - self.assertEqual(1, len(list(checks.check_assert_called_once( - ".assert_called_once(", "cinder/tests/unit/test1.py")))) - self.assertEqual(0, len(list(checks.check_assert_called_once( - ".assertEqual(", "cinder/tests/unit/test1.py")))) - def test_oslo_namespace_imports_check(self): self.assertEqual(1, len(list(checks.check_oslo_namespace_imports( "from oslo.concurrency import foo")))) -- 2.45.2