diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-03 18:20:48 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-03 18:20:48 +0300 |
commit | 95ee5b2825c1de2e2fd988c9fa8f6c41394a2823 (patch) | |
tree | 9e60e9b6c2fde6a76dca748ba9783bbd71151df9 | |
parent | ccec0df4c7d3e664ea95e18ade40856d230a7152 (diff) | |
download | pylint-95ee5b2825c1de2e2fd988c9fa8f6c41394a2823.tar.gz |
Port more old tests to the new style tests and remove obsolete tests.
24 files changed, 74 insertions, 205 deletions
diff --git a/pylint/test/functional/access_to_protected_members.py b/pylint/test/functional/access_to_protected_members.py index 84eaaec..9c92306 100644 --- a/pylint/test/functional/access_to_protected_members.py +++ b/pylint/test/functional/access_to_protected_members.py @@ -23,11 +23,16 @@ class MyClass(object): print(cls._cls_protected) clsmeth = classmethod(clsmeth) + def _private_method(self): + """Doing nothing.""" + + class Subclass(MyClass): """Subclass with protected members.""" def __init__(self): MyClass._protected = 5 + super(Subclass, self)._private_method() INST = Subclass() INST.attr = 1 diff --git a/pylint/test/functional/access_to_protected_members.txt b/pylint/test/functional/access_to_protected_members.txt index b933c23..123c1dd 100644 --- a/pylint/test/functional/access_to_protected_members.txt +++ b/pylint/test/functional/access_to_protected_members.txt @@ -1,5 +1,5 @@ protected-access:18:MyClass.test:Access to a protected member _haha of a client class -protected-access:35::Access to a protected member _protected of a client class -protected-access:36::Access to a protected member _protected of a client class -protected-access:37::Access to a protected member _cls_protected of a client class -protected-access:38::Access to a protected member _cls_protected of a client class +protected-access:40::Access to a protected member _protected of a client class +protected-access:41::Access to a protected member _protected of a client class +protected-access:42::Access to a protected member _cls_protected of a client class +protected-access:43::Access to a protected member _cls_protected of a client class diff --git a/pylint/test/functional/bad_indentation.py b/pylint/test/functional/bad_indentation.py new file mode 100644 index 0000000..c868aed --- /dev/null +++ b/pylint/test/functional/bad_indentation.py @@ -0,0 +1,20 @@ +# pylint: disable=missing-docstring, pointless-statement +from __future__ import print_function + + +def totoo(): + print('malindented') # [bad-indentation] + +def tutuu(): + print('good indentation') + +def titii(): + 1 # and this. # [bad-indentation] + +def tataa(kdict): + for key in ['1', '2', '3']: + key = key.lower() + + if key in kdict: + del kdict[key] + diff --git a/pylint/test/functional/bad_indentation.txt b/pylint/test/functional/bad_indentation.txt new file mode 100644 index 0000000..c5c00bb --- /dev/null +++ b/pylint/test/functional/bad_indentation.txt @@ -0,0 +1,2 @@ +bad-indentation:6::Bad indentation. Found 1 spaces, expected 4 +bad-indentation:12::Bad indentation. Found 5 spaces, expected 4 diff --git a/pylint/test/functional/invalid_all_object.py b/pylint/test/functional/invalid_all_object.py new file mode 100644 index 0000000..4468c98 --- /dev/null +++ b/pylint/test/functional/invalid_all_object.py @@ -0,0 +1,6 @@ +# pylint: disable=missing-docstring
+__all__ = (
+ 1, # [invalid-all-object]
+ lambda: None, # [invalid-all-object]
+ None, # [invalid-all-object]
+)
diff --git a/pylint/test/functional/invalid_all_object.txt b/pylint/test/functional/invalid_all_object.txt new file mode 100644 index 0000000..eaec65b --- /dev/null +++ b/pylint/test/functional/invalid_all_object.txt @@ -0,0 +1,3 @@ +invalid-all-object:3::Invalid object '1' in __all__, must contain only strings
+invalid-all-object:4:<lambda>:"Invalid object 'lambda : None' in __all__, must contain only strings"
+invalid-all-object:5::Invalid object 'None' in __all__, must contain only strings
\ No newline at end of file diff --git a/pylint/test/functional/member_checks.py b/pylint/test/functional/member_checks.py index 47e67ec..8838fae 100644 --- a/pylint/test/functional/member_checks.py +++ b/pylint/test/functional/member_checks.py @@ -144,3 +144,32 @@ class SuperChecks(str, str): # pylint: disable=duplicate-bases type(Client()).ala # [no-member] type({}).bala # [no-member] type('').portocala # [no-member] + + +def socket_false_positive(): + """Test a regression + Version used: + + - Pylint 0.10.0 + - Logilab common 0.15.0 + - Logilab astroid 0.15.1 + + False E1101 positive, line 23: + Instance of '_socketobject' has no 'connect' member + """ + + import socket + sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sckt.connect(('127.0.0.1', 80)) + sckt.close() + + +def no_conjugate_member(magic_flag): + """should not raise E1101 on something.conjugate""" + if magic_flag: + something = 1.0 + else: + something = 1.0j + if isinstance(something, float): + return something + return something.conjugate() diff --git a/pylint/test/functional/undefined_variable.py b/pylint/test/functional/undefined_variable.py index b97bdd5..44a0652 100644 --- a/pylint/test/functional/undefined_variable.py +++ b/pylint/test/functional/undefined_variable.py @@ -1,4 +1,4 @@ -"""Test warnings about access to undefined variables.""" +# pylint: disable=missing-docstring, multiple-statements # pylint: disable=too-few-public-methods, no-init, no-self-use, old-style-class,bare-except,broad-except from __future__ import print_function DEFINED = 1 @@ -171,3 +171,7 @@ try: unicode_4 # [undefined-variable] except ValueError: pass + +# See https://bitbucket.org/logilab/pylint/issue/111/ +try: raise IOError(1, "a") +except IOError as err: print(err) diff --git a/pylint/test/input/func_indent.py b/pylint/test/input/func_indent.py deleted file mode 100644 index fa58d0d..0000000 --- a/pylint/test/input/func_indent.py +++ /dev/null @@ -1,24 +0,0 @@ -# pylint: disable=print-statement -"""docstring""" -from __future__ import print_function - -def totoo(): - """docstring""" - print('malindented') - -def tutuu(): - """docstring""" - print('good indentation') - -def titii(): - """also malindented""" - 1 # and this. - -def tataa(kdict): - """blank line unindented""" - for key in ['1', '2', '3']: - key = key.lower() - - if kdict.has_key(key): - del kdict[key] - diff --git a/pylint/test/input/func_more_e0604.py b/pylint/test/input/func_more_e0604.py deleted file mode 100644 index 6c39e1c..0000000 --- a/pylint/test/input/func_more_e0604.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Test for invalid objects in a module's __all__ variable. - -""" -# pylint: disable=R0903,R0201,W0612 - -__revision__ = 0 - - -__all__ = [1] diff --git a/pylint/test/input/func_noerror_e1101_13784.py b/pylint/test/input/func_noerror_e1101_13784.py deleted file mode 100644 index b247b44..0000000 --- a/pylint/test/input/func_noerror_e1101_13784.py +++ /dev/null @@ -1,15 +0,0 @@ -"""cf #13784 -""" - -__revision__ = None - -def no_conjugate_member(magic_flag): - """should not raise E1101 on something.conjugate""" - if magic_flag: - something = 1.0 - else: - something = 1.0j - if isinstance(something, float): - return something - return something.conjugate() - diff --git a/pylint/test/input/func_noerror_e1101_but_getattr.py b/pylint/test/input/func_noerror_e1101_but_getattr.py deleted file mode 100644 index 529b413..0000000 --- a/pylint/test/input/func_noerror_e1101_but_getattr.py +++ /dev/null @@ -1,23 +0,0 @@ -"""don't want E1101 if __getattr__ is defined""" -from __future__ import print_function -__revision__ = None - -class MyString(object): - """proxied string""" - - def __init__(self, string): - self.string = string - - def __getattr__(self, attr): - return getattr(self.string, attr) - - def lower(self): - """string.lower""" - return self.string.lower() - - def upper(self): - """string.upper""" - return self.string.upper() - -MYSTRING = MyString("abc") -print(MYSTRING.title()) diff --git a/pylint/test/input/func_noerror_indirect_interface.py b/pylint/test/input/func_noerror_indirect_interface.py deleted file mode 100644 index 66e3757..0000000 --- a/pylint/test/input/func_noerror_indirect_interface.py +++ /dev/null @@ -1,16 +0,0 @@ -"""shows a bug where pylint can't find interfaces when they are -used indirectly. See input/indirect[123].py for details on the -setup""" -# pylint: disable=old-style-class, too-few-public-methods, no-absolute-import -__revision__ = None - -from .indirect2 import AbstractToto - -class ConcreteToto(AbstractToto): - """abstract to implements an interface requiring machin to be defined""" - def __init__(self): - self.duh = 2 - - def machin(self): - """for ifacd""" - return self.helper()*2 diff --git a/pylint/test/input/func_noerror_nested_classes.py b/pylint/test/input/func_noerror_nested_classes.py deleted file mode 100644 index 84465a4..0000000 --- a/pylint/test/input/func_noerror_nested_classes.py +++ /dev/null @@ -1,18 +0,0 @@ -# pylint: disable=R0903 -"""crash test""" - -from __future__ import print_function - -class Temelekefe(object): - """gloubliboulga""" - - def __init__(self): - """nested class with function raise error""" - class Toto(object): - """toto nested class""" - def __init__(self): - self.attr = 2 - def toto_method(self): - """toto nested class method""" - print(self) - print('error ?', self, Toto) diff --git a/pylint/test/input/func_noerror_socket_member.py b/pylint/test/input/func_noerror_socket_member.py deleted file mode 100644 index 1cdafe6..0000000 --- a/pylint/test/input/func_noerror_socket_member.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Testing Pylint with the socket module - -Pylint Problem -============== - -Version used: - - - Pylint 0.10.0 - - Logilab common 0.15.0 - - Logilab astroid 0.15.1 - -False E1101 positive, line 23: - - Instance of '_socketobject' has no 'connect' member - -""" -from __future__ import absolute_import -__revision__ = None -import socket - -if __name__ == "__main__": - - SCKT = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - SCKT.connect(('127.0.0.1', 80)) - SCKT.close() diff --git a/pylint/test/input/func_noerror_super_protected.py b/pylint/test/input/func_noerror_super_protected.py deleted file mode 100644 index b4a5517..0000000 --- a/pylint/test/input/func_noerror_super_protected.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Accessing a protected method through super() is ok.""" - -# pylint: disable=missing-docstring,too-few-public-methods - -from __future__ import print_function - -class Alpha(object): - - _secret = 2 - - def test(self): - print("test %s" % self) - - -class Beta(Alpha): - - def test(self): - print(super(Beta, self)._secret) - super(Beta, self).test() - - -Beta().test() diff --git a/pylint/test/input/func_noerror_unused_variable_py30.py b/pylint/test/input/func_noerror_unused_variable_py30.py deleted file mode 100644 index ffcc978..0000000 --- a/pylint/test/input/func_noerror_unused_variable_py30.py +++ /dev/null @@ -1,14 +0,0 @@ -""" Test nonlocal uses and unused-variable. """ - -__revision__ = 1 - -def test_nonlocal(): - """ Test that assigning to a nonlocal does not trigger - an 'unused-variable' warnings. - """ - attr = True - def set_value(val): - """ Set the value in a nonlocal. """ - nonlocal attr - attr = val - return set_value diff --git a/pylint/test/input/func_noerror_used_before_assignment.py b/pylint/test/input/func_noerror_used_before_assignment.py deleted file mode 100644 index ec7643b..0000000 --- a/pylint/test/input/func_noerror_used_before_assignment.py +++ /dev/null @@ -1,5 +0,0 @@ -# pylint: disable = line-too-long, multiple-statements -"""https://bitbucket.org/logilab/pylint/issue/111/false-positive-used-before-assignment-with""" -from __future__ import print_function -try: raise IOError(1, "a") -except IOError as err: print(err) diff --git a/pylint/test/input/func_noerror_w0232.py b/pylint/test/input/func_noerror_w0232.py deleted file mode 100644 index 75b68df..0000000 --- a/pylint/test/input/func_noerror_w0232.py +++ /dev/null @@ -1,7 +0,0 @@ -# pylint: disable=R0903 -"""check interface and exception without __init__ doesn't print warnings -""" -__revision__ = '' - -class MyError(Exception): - """exception without docstring""" diff --git a/pylint/test/input/indirect1.py b/pylint/test/input/indirect1.py deleted file mode 100644 index eac6242..0000000 --- a/pylint/test/input/indirect1.py +++ /dev/null @@ -1,4 +0,0 @@ -class TotoInterface: - def machin(self): - raise NotImplementedError - diff --git a/pylint/test/input/indirect2.py b/pylint/test/input/indirect2.py deleted file mode 100644 index 85977f0..0000000 --- a/pylint/test/input/indirect2.py +++ /dev/null @@ -1,7 +0,0 @@ -from .indirect1 import TotoInterface - -class AbstractToto: - __implements__ = TotoInterface - - def helper(self): - return 'help' diff --git a/pylint/test/input/indirect3.py b/pylint/test/input/indirect3.py deleted file mode 100644 index dac0853..0000000 --- a/pylint/test/input/indirect3.py +++ /dev/null @@ -1,5 +0,0 @@ -from indirect2 import AbstractToto - -class ConcreteToto(AbstractToto): - def machin(self): - return self.helper()*2 diff --git a/pylint/test/messages/func_indent.txt b/pylint/test/messages/func_indent.txt deleted file mode 100644 index c8fe133..0000000 --- a/pylint/test/messages/func_indent.txt +++ /dev/null @@ -1,5 +0,0 @@ -W: 6: Bad indentation. Found 1 spaces, expected 4 -W: 7: Bad indentation. Found 1 spaces, expected 4 -W: 14: Bad indentation. Found 5 spaces, expected 4 -W: 15: Bad indentation. Found 5 spaces, expected 4 -W: 15:titii: Statement seems to have no effect diff --git a/pylint/test/messages/func_more_e0604.txt b/pylint/test/messages/func_more_e0604.txt deleted file mode 100644 index 080c59f..0000000 --- a/pylint/test/messages/func_more_e0604.txt +++ /dev/null @@ -1 +0,0 @@ -E: 9: Invalid object '1' in __all__, must contain only strings |