From 7bc82747f61593276de136b302b319d402bb010a Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Mon, 1 Jun 2015 00:39:36 +0300 Subject: Add tests for checking the new understanding of super calls. --- pylint/test/functional/super_checks.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'pylint/test/functional/super_checks.py') diff --git a/pylint/test/functional/super_checks.py b/pylint/test/functional/super_checks.py index a2319fe..14fd5a2 100644 --- a/pylint/test/functional/super_checks.py +++ b/pylint/test/functional/super_checks.py @@ -1,4 +1,4 @@ -# pylint: disable=too-few-public-methods,import-error, no-absolute-import +# pylint: disable=too-few-public-methods,import-error, no-absolute-import,missing-docstring """check use of super""" from unknown import Missing @@ -68,3 +68,31 @@ class UnknownBases(Missing): # pylint: disable=super-on-old-class super(UnknownBases, self).__init__() super(UnknownBases, self).test() + + +# Test that we are detecting proper super errors. + +class BaseClass(object): + + not_a_method = 42 + + def function(self, param): + return param + self.not_a_method + + def __getattr__(self, attr): + return attr + + +class InvalidSuperChecks(BaseClass): + + def __init__(self): + super(InvalidSuperChecks, self).not_a_method() # [not-callable] + super(InvalidSuperChecks, self).attribute_error() # [no-member] + super(InvalidSuperChecks, self).function(42) + super(InvalidSuperChecks, self).function() # [no-value-for-parameter] + super(InvalidSuperChecks, self).function(42, 24, 24) # [too-many-function-args] + # +1: [unexpected-keyword-arg,no-value-for-parameter] + super(InvalidSuperChecks, self).function(lala=42) + # Even though BaseClass has a __getattr__, that won't + # be called. + super(InvalidSuperChecks, self).attribute_error() # [no-member] -- cgit v1.2.1