From 8735b76d557aec6f1a6ee60db860fca54385b7de Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Sat, 12 Oct 2013 13:48:32 +0800 Subject: [PATCH] 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 --- hacking/core.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hacking/core.py b/hacking/core.py index 8b440fef..d275ce76 100755 --- a/hacking/core.py +++ b/hacking/core.py @@ -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