Add check for deprecated method assertEquals

The proper one is assertEqual, assertEquals is deprecated as of 2.7.
Of course, remembering which one is good and which one is bad is
absolutely impossible.

Change-Id: I79c5417ea2d11091ed7d73cf28c534feef6f7ba9
This commit is contained in:
Monty Taylor
2013-07-06 15:15:31 -04:00
parent 6e1404cb22
commit 9679b5707d
2 changed files with 17 additions and 0 deletions

View File

@@ -639,6 +639,22 @@ def hacking_no_cr(physical_line):
return (pos, "H601: Windows style line endings not allowed in code")
@flake8ext
def hacking_no_assert_equals(logical_line, tokens):
r"""assertEquals() is deprecated, use assertEqual instead.
Okay: self.assertEqual(0, 0)
H602: self.assertEquals(0, 0)
"""
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")
FORMAT_RE = re.compile("%(?:"
"%|" # Ignore plain percents
"(\(\w+\))?" # mapping key

View File

@@ -39,6 +39,7 @@ flake8.extension =
H404 = hacking.core:hacking_docstring_multiline_start
H501 = hacking.core:hacking_no_locals
H601 = hacking.core:hacking_no_cr
H602 = hacking.core:hacking_no_assert_equals
H700 = hacking.core:hacking_localization_strings
H801 = hacking.core:OnceGitCheckCommitTitleBug
H802 = hacking.core:OnceGitCheckCommitTitleLength