]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove hacking check N327
authorEric Harney <eharney@redhat.com>
Fri, 10 Jul 2015 14:25:50 +0000 (10:25 -0400)
committerEric Harney <eharney@redhat.com>
Fri, 10 Jul 2015 14:44:47 +0000 (10:44 -0400)
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
cinder/hacking/checks.py
cinder/tests/unit/test_hacking.py

index f0cdbad9ba130b4341652eff6c6f440e96b36493..b0e412311a6cc92b67272274a798b2350d59f6a7 100644 (file)
@@ -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()`.
index bb33e445e93dd9113065870b63eecc1e18c15d4f..e130b077c738bbb3c348dc5a6c679d4c9a0908c2 100644 (file)
@@ -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)
index 4f0cd889453a52db76255dddd5ef72a023fe7d72..62214480b14b72cd64adc26d1cd6bd22845c018f 100644 (file)
@@ -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"))))