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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user