diff options
Diffstat (limited to 'pylint')
| -rw-r--r-- | pylint/checkers/stdlib.py | 9 | ||||
| -rw-r--r-- | pylint/test/functional/deprecated_methods_py2.py | 13 | ||||
| -rw-r--r-- | pylint/test/functional/deprecated_methods_py2.txt | 13 |
3 files changed, 29 insertions, 6 deletions
diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index 37619cbb4..87124b43d 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -132,6 +132,13 @@ class StdlibChecker(BaseChecker): 'distutils.command.sdist.sdist.check_metadata', 'tkinter.Misc.tk_menuBar', 'tkinter.Menu.tk_bindForTraversal', + + # These are aliases for `assertEqual` et al. + 'assertEquals', + 'assertNotEquals', + 'assertAlmostEquals', + 'assertNotAlmostEquals', + 'assert_', ], 2: { (2, 6, 0): [ @@ -270,7 +277,7 @@ class StdlibChecker(BaseChecker): return qname = inferred.qname() - if qname in self.deprecated[0]: + if any(name in self.deprecated[0] for name in (qname, func_name)): self.add_message('deprecated-method', node=node, args=(func_name, )) else: diff --git a/pylint/test/functional/deprecated_methods_py2.py b/pylint/test/functional/deprecated_methods_py2.py index ceba1e4f9..08f80aeba 100644 --- a/pylint/test/functional/deprecated_methods_py2.py +++ b/pylint/test/functional/deprecated_methods_py2.py @@ -1,9 +1,20 @@ """ Functional test for deprecated methods in Python 2 """ -# pylint: disable=no-member +# pylint: disable=no-member,missing-docstring import os import xml.etree.ElementTree +import unittest os.popen2('') # [deprecated-method] os.popen3('') # [deprecated-method] os.popen4('') # [deprecated-method] xml.etree.ElementTree.Element('elem').getchildren() # [deprecated-method] + + +class Tests(unittest.TestCase): + + def test_foo(self): + self.assertEquals(2 + 2, 4) # [deprecated-method] + self.assertNotEquals(2 + 2, 4) # [deprecated-method] + self.assertAlmostEquals(2 + 2, 4) # [deprecated-method] + self.assertNotAlmostEquals(2 + 2, 4) # [deprecated-method] + self.assert_("abc" == "2") # [deprecated-method] diff --git a/pylint/test/functional/deprecated_methods_py2.txt b/pylint/test/functional/deprecated_methods_py2.txt index e1038185c..a09f4bd0a 100644 --- a/pylint/test/functional/deprecated_methods_py2.txt +++ b/pylint/test/functional/deprecated_methods_py2.txt @@ -1,4 +1,9 @@ -deprecated-method:6::Using deprecated method popen2() -deprecated-method:7::Using deprecated method popen3() -deprecated-method:8::Using deprecated method popen4() -deprecated-method:9::Using deprecated method getchildren() +deprecated-method:7::Using deprecated method popen2() +deprecated-method:8::Using deprecated method popen3() +deprecated-method:9::Using deprecated method popen4() +deprecated-method:10::Using deprecated method getchildren() +deprecated-method:16:Tests.test_foo:Using deprecated method assertEquals() +deprecated-method:17:Tests.test_foo:Using deprecated method assertNotEquals() +deprecated-method:18:Tests.test_foo:Using deprecated method assertAlmostEquals() +deprecated-method:19:Tests.test_foo:Using deprecated method assertNotAlmostEquals() +deprecated-method:20:Tests.test_foo:Using deprecated method assert_() |
