Merge "Revert "Add hacking check to prevent assert_called_once""

This commit is contained in:
Jenkins 2016-05-25 03:51:44 +00:00 committed by Gerrit Code Review
commit a17d3e2961
3 changed files with 0 additions and 17 deletions

View File

@ -30,7 +30,6 @@ Cinder Specific Commandments
- [C311] Check for proper naming and usage in option registration. - [C311] Check for proper naming and usage in option registration.
- [C312] Check that assertIsNone(value) is used and not assertEqual(None, value). - [C312] Check that assertIsNone(value) is used and not assertEqual(None, value).
- [C313] Check that assertTrue(value) is used and not assertEqual(True, value). - [C313] Check that assertTrue(value) is used and not assertEqual(True, value).
- [C314] Check for use of invalid mock.assert_called_once().
General General
------- -------

View File

@ -504,15 +504,6 @@ def validate_assertTrue(logical_line):
yield(0, msg) yield(0, msg)
def no_assert_called_once(logical_line, filename):
if "cinder/tests" not in filename or "test_hacking" in filename:
return
msg = ("C314: assert_called_once is not a valid mock assertion, "
"use assert_equal(1, mocked.call_count) instead.")
if 'assert_called_once(' in logical_line:
yield (0, msg)
def factory(register): def factory(register):
register(no_vi_headers) register(no_vi_headers)
register(no_translate_debug_logs) register(no_translate_debug_logs)
@ -535,4 +526,3 @@ def factory(register):
register(no_test_log) register(no_test_log)
register(validate_assertIsNone) register(validate_assertIsNone)
register(validate_assertTrue) register(validate_assertTrue)
register(no_assert_called_once)

View File

@ -448,9 +448,3 @@ class HackingTestCase(test.TestCase):
def test_no_test_log(self, first, second, third, fourth): def test_no_test_log(self, first, second, third, fourth):
self.assertEqual(first, len(list(checks.no_test_log( self.assertEqual(first, len(list(checks.no_test_log(
"%s('arg')" % second, third, fourth)))) "%s('arg')" % second, third, fourth))))
def test_no_assert_called_once(self):
self.assertEqual(1, len(list(checks.no_assert_called_once(
"masker.assert_called_once(", "cinder/tests/unit/fake.py"))))
self.assertEqual(0, len(list(checks.no_assert_called_once(
"masker.assert_called_once_with(", "cinder/tests/unit/fake.py"))))