Add assertNotEquals check to H602

There are some projects that mix assertNotEqual and assertNotEquals
in their testscripts. According to Python 3 source code, assertNotEquals
is also deprecated. This patch adds a check for assertNotEquals in H602 since
it already handles assertEquals and has not been released yet.

Lib/unittest/case.py:
    failIfEqual = assertNotEquals = _deprecate(assertNotEqual)

Change-Id: I087bd4b23cb2daa59a1df32926ddcc5cc2052f5c
This commit is contained in:
Zhongyue Luo 2013-10-12 13:48:32 +08:00
parent 9c62571b9f
commit 8735b76d55

View File

@ -673,18 +673,20 @@ def hacking_no_cr(physical_line):
@flake8ext
def hacking_no_assert_equals(logical_line, tokens):
r"""assertEquals() is deprecated, use assertEqual instead.
r"""assert(Not)Equals() is deprecated, use assert(Not)Equal instead.
Okay: self.assertEqual(0, 0)
Okay: self.assertNotEqual(0, 1)
H602: self.assertEquals(0, 0)
H602: self.assertNotEquals(0, 1)
"""
for token_type, text, start_index, _, _ in tokens:
if token_type == tokenize.NAME and text == "assertEquals":
yield (
start_index[1],
"H602: assertEquals is deprecated, use assertEqual")
if token_type == tokenize.NAME:
if text == "assertEquals" or text == "assertNotEquals":
yield (start_index[1],
"H602: %s is deprecated, use %s" % (text, text[:-1]))
@flake8ext