Remove duplicated hacking rule Z318
Change-Id: I143892498b4c375c1c6a53000f81251d3c04a1b9 Closes-Bug: #1696466
This commit is contained in:
parent
888ebd5c34
commit
340894ae84
@ -12,8 +12,6 @@ Zun Specific Commandments
|
||||
datetime.datetime.utcnow() to make it easy to override its return value.
|
||||
- [Z316] Change assertTrue(isinstance(A, B)) by optimal assert like
|
||||
assertIsInstance(A, B).
|
||||
- [Z318] Change assertEqual(A, None) or assertEqual(None, A) by optimal assert
|
||||
like assertIsNone(A)
|
||||
- [Z322] Method's default argument shouldn't be mutable.
|
||||
- [Z323] Change assertEqual(True, A) or assertEqual(False, A) by optimal assert
|
||||
like assertTrue(A) or assertFalse(A)
|
||||
|
@ -35,10 +35,6 @@ assert_equal_in_end_with_true_or_false_re = re.compile(
|
||||
r"assertEqual\((\w|[][.'\"])+ in (\w|[][.'\", ])+, (True|False)\)")
|
||||
assert_equal_in_start_with_true_or_false_re = re.compile(
|
||||
r"assertEqual\((True|False), (\w|[][.'\"])+ in (\w|[][.'\", ])+\)")
|
||||
assert_equal_end_with_none_re = re.compile(
|
||||
r"(.)*assertEqual\((\w|\.|\'|\"|\[|\])+, None\)")
|
||||
assert_equal_start_with_none_re = re.compile(
|
||||
r"(.)*assertEqual\(None, (\w|\.|\'|\"|\[|\])+\)")
|
||||
assert_equal_with_true_re = re.compile(
|
||||
r"assertEqual\(True,")
|
||||
assert_equal_with_false_re = re.compile(
|
||||
@ -53,19 +49,6 @@ assert_xrange_re = re.compile(
|
||||
r"\s*xrange\s*\(")
|
||||
|
||||
|
||||
def assert_equal_none(logical_line):
|
||||
"""Check for assertEqual(A, None) or assertEqual(None, A) sentences
|
||||
|
||||
Z318
|
||||
"""
|
||||
msg = ("Z318: assertEqual(A, None) or assertEqual(None, A) "
|
||||
"sentences not allowed")
|
||||
res = (assert_equal_start_with_none_re.match(logical_line) or
|
||||
assert_equal_end_with_none_re.match(logical_line))
|
||||
if res:
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
def no_mutable_default_args(logical_line):
|
||||
msg = "Z322: Method's default argument shouldn't be mutable!"
|
||||
if mutable_default_args.match(logical_line):
|
||||
@ -160,7 +143,6 @@ def no_log_warn(logical_line):
|
||||
|
||||
def factory(register):
|
||||
register(no_mutable_default_args)
|
||||
register(assert_equal_none)
|
||||
register(assert_equal_true_or_false)
|
||||
register(assert_equal_not_none)
|
||||
register(assert_true_isinstance)
|
||||
|
@ -117,19 +117,6 @@ class HackingTestCase(base.BaseTestCase):
|
||||
code = "self.assertEqual(False, any(a==1 for a in b))"
|
||||
self._assert_has_no_errors(code, check)
|
||||
|
||||
def test_assert_equal_none(self):
|
||||
errors = [(1, 0, "Z318")]
|
||||
check = checks.assert_equal_none
|
||||
|
||||
code = "self.assertEqual(A, None)"
|
||||
self._assert_has_errors(code, check, errors)
|
||||
|
||||
code = "self.assertEqual(None, A)"
|
||||
self._assert_has_errors(code, check, errors)
|
||||
|
||||
code = "self.assertIsNone()"
|
||||
self._assert_has_no_errors(code, check)
|
||||
|
||||
def test_assert_equal_true_or_false(self):
|
||||
errors = [(1, 0, "Z323")]
|
||||
check = checks.assert_equal_true_or_false
|
||||
|
Loading…
Reference in New Issue
Block a user