diff options
author | Torsten Marek <shlomme@gmail.com> | 2014-11-22 14:30:15 +0100 |
---|---|---|
committer | Torsten Marek <shlomme@gmail.com> | 2014-11-22 14:30:15 +0100 |
commit | e0c681e65138e9f69567cfdaadb89ec603129608 (patch) | |
tree | 92953c30ffe676b1fe5efa82aaf7a897f6ca2113 | |
parent | 17caeca58b0dce1605545e1b70d263af51a8e638 (diff) | |
download | pylint-e0c681e65138e9f69567cfdaadb89ec603129608.tar.gz |
Convert some testcases to the new framework.
18 files changed, 64 insertions, 70 deletions
diff --git a/test/input/func_w0231.py b/test/functional/init_not_called.py index ce140ff..e22be39 100644 --- a/test/input/func_w0231.py +++ b/test/functional/init_not_called.py @@ -1,29 +1,28 @@ -# pylint: disable=R0903,no-init +# pylint: disable=R0903 """test for __init__ not called """ from __future__ import print_function -__revision__ = '$Id: func_w0231.py,v 1.3 2004-09-29 08:35:13 syt Exp $' -class AAAA: +class AAAA: # <3.0:[old-style-class] """ancestor 1""" def __init__(self): print('init', self) -class BBBB: +class BBBB: # <3.0:[old-style-class] """ancestor 2""" def __init__(self): print('init', self) -class CCCC: +class CCCC: # <3.0:[old-style-class,no-init] """ancestor 3""" class ZZZZ(AAAA, BBBB, CCCC): """derived class""" - def __init__(self): + def __init__(self): # [super-init-not-called] AAAA.__init__(self) class NewStyleA(object): @@ -56,5 +55,5 @@ class NewStyleC(object): class AssignedInit(NewStyleC): """No init called.""" - def __init__(self): + def __init__(self): # [super-init-not-called] self.arg = 0 diff --git a/test/functional/init_not_called.txt b/test/functional/init_not_called.txt new file mode 100644 index 0000000..b0bc418 --- /dev/null +++ b/test/functional/init_not_called.txt @@ -0,0 +1,6 @@ +old-style-class:6:AAAA:Old-style class defined. +old-style-class:12:BBBB:Old-style class defined. +no-init:18:CCCC:Class has no __init__ method +old-style-class:18:CCCC:Old-style class defined. +super-init-not-called:25:ZZZZ.__init__:__init__ method from base class 'BBBB' is not called +super-init-not-called:58:AssignedInit.__init__:__init__ method from base class 'NewStyleC' is not called diff --git a/test/functional/no_name_in_module.py b/test/functional/no_name_in_module.py new file mode 100644 index 0000000..dc384b3 --- /dev/null +++ b/test/functional/no_name_in_module.py @@ -0,0 +1,26 @@ +#pylint: disable=W0401,W0611,print-statement,no-absolute-import +"""check unexistant names imported are reported""" + + +import logilab.common.tutu # [no-name-in-module,import-error] +from logilab.common import toto # [no-name-in-module] +toto.yo() + +from logilab.common import modutils +modutils.nonexistant_function() # [no-member] +modutils.another.nonexistant.function() # [no-member] +print logilab.common.modutils.yo # [no-member] + +import sys +print >> sys.stdout, 'hello world' +print >> sys.stdoout, 'bye bye world' # [no-member] + + +import re +re.finditer('*', 'yo') + +from rie import * # [import-error] +from re import findiiter, compiile # [no-name-in-module,no-name-in-module] + +import os +'SOMEVAR' in os.environ # [pointless-statement] diff --git a/test/functional/no_name_in_module.txt b/test/functional/no_name_in_module.txt new file mode 100644 index 0000000..6961d83 --- /dev/null +++ b/test/functional/no_name_in_module.txt @@ -0,0 +1,11 @@ +import-error:5::Unable to import 'logilab.common.tutu' +no-name-in-module:5::No name 'tutu' in module 'logilab.common' +no-name-in-module:6::No name 'toto' in module 'logilab.common' +no-member:10::Module 'logilab.common.modutils' has no 'nonexistant_function' member:INFERENCE +no-member:11::Module 'logilab.common.modutils' has no 'another' member:INFERENCE +no-member:12::Module 'logilab.common.modutils' has no 'yo' member:INFERENCE +no-member:16::Module 'sys' has no 'stdoout' member:INFERENCE +import-error:22::Unable to import 'rie' +no-name-in-module:23::No name 'compiile' in module 're' +no-name-in-module:23::No name 'findiiter' in module 're' +pointless-statement:26::Statement seems to have no effect diff --git a/test/input/func_bad_slots.py b/test/functional/slots_checks.py index f35906c..d49681b 100644 --- a/test/input/func_bad_slots.py +++ b/test/functional/slots_checks.py @@ -10,7 +10,6 @@ def func(): else: return [str(var) for var in range(3)] -__revision__ = 0 class NotIterable(object): def __iter_(self): @@ -40,17 +39,17 @@ class SeventhGood(object): class Bad(object): __slots__ = list -class SecondBad(object): +class SecondBad(object): # [invalid-slots] __slots__ = 1 class ThirdBad(object): - __slots__ = ('a', 2) + __slots__ = ('a', 2) # [invalid-slots-object] -class FourthBad(object): +class FourthBad(object): # [invalid-slots] __slots__ = NotIterable() class FifthBad(object): - __slots__ = ("a", "b", "") + __slots__ = ("a", "b", "") # [invalid-slots-object] class PotentiallyGood(object): __slots__ = func() diff --git a/test/functional/slots_checks.txt b/test/functional/slots_checks.txt new file mode 100644 index 0000000..7e90a4a --- /dev/null +++ b/test/functional/slots_checks.txt @@ -0,0 +1,4 @@ +invalid-slots:42:SecondBad:Invalid __slots__ object +invalid-slots-object:46:ThirdBad:Invalid object '2' in __slots__, must contain only non empty strings +invalid-slots:48:FourthBad:Invalid __slots__ object +invalid-slots-object:52:FifthBad:"Invalid object ""''"" in __slots__, must contain only non empty strings" diff --git a/test/input/func_with_used_before_assignment.py b/test/functional/with_used_before_assign.py index c79815c..64a475a 100644 --- a/test/input/func_with_used_before_assignment.py +++ b/test/functional/with_used_before_assign.py @@ -3,10 +3,9 @@ Regression test for https://bitbucket.org/logilab/pylint/issue/128/attributeerror-when-parsing ''' from __future__ import with_statement -__revision__ = 1 def do_nothing(): """ empty """ - with open("") as ctx.obj: - context.do() + with open("") as ctx.obj: # [undefined-variable] + context.do() # [used-before-assignment] context = None diff --git a/test/functional/with_used_before_assign.txt b/test/functional/with_used_before_assign.txt new file mode 100644 index 0000000..783ae73 --- /dev/null +++ b/test/functional/with_used_before_assign.txt @@ -0,0 +1,2 @@ +undefined-variable:9:do_nothing:Undefined variable 'ctx' +used-before-assignment:10:do_nothing:Using variable 'context' before assignment diff --git a/test/input/func_yield_outside_func.py b/test/functional/yield_outside_func.py index c1ea3bd..5824bc0 100644 --- a/test/input/func_yield_outside_func.py +++ b/test/functional/yield_outside_func.py @@ -1,5 +1,4 @@ """This is gramatically correct, but it's still a SyntaxError""" -__revision__ = None -yield 1 +yield 1 # [yield-outside-function] LAMBDA_WITH_YIELD = lambda: (yield) diff --git a/test/functional/yield_outside_func.txt b/test/functional/yield_outside_func.txt new file mode 100644 index 0000000..fa3a7fc --- /dev/null +++ b/test/functional/yield_outside_func.txt @@ -0,0 +1 @@ +yield-outside-function:2::Yield outside function diff --git a/test/input/func_names_imported_from_module.py b/test/input/func_names_imported_from_module.py deleted file mode 100644 index 578cb7d..0000000 --- a/test/input/func_names_imported_from_module.py +++ /dev/null @@ -1,27 +0,0 @@ -#pylint: disable=W0401,W0611,print-statement,no-absolute-import -"""check unexistant names imported are reported""" - -__revision__ = None - -import logilab.common.tutu -from logilab.common import toto -toto.yo() - -from logilab.common import modutils -modutils.nonexistant_function() -modutils.another.nonexistant.function() -print logilab.common.modutils.yo - -import sys -print >> sys.stdout, 'hello world' -print >> sys.stdoout, 'bye bye world' - - -import re -re.finditer('*', 'yo') - -from rie import * -from re import findiiter, compiile - -import os -'SOMEVAR' in os.environ diff --git a/test/messages/func_bad_slots.txt b/test/messages/func_bad_slots.txt deleted file mode 100644 index ec44646..0000000 --- a/test/messages/func_bad_slots.txt +++ /dev/null @@ -1,4 +0,0 @@ -E: 43:SecondBad: Invalid __slots__ object
-E: 47:ThirdBad: Invalid object '2' in __slots__, must contain only non empty strings
-E: 49:FourthBad: Invalid __slots__ object
-E: 53:FifthBad: Invalid object "''" in __slots__, must contain only non empty strings
\ No newline at end of file diff --git a/test/messages/func_names_imported_from_module.txt b/test/messages/func_names_imported_from_module.txt deleted file mode 100644 index 23362ba..0000000 --- a/test/messages/func_names_imported_from_module.txt +++ /dev/null @@ -1,11 +0,0 @@ -E: 6: No name 'tutu' in module 'logilab.common' -E: 7: No name 'toto' in module 'logilab.common' -E: 11: Module 'logilab.common.modutils' has no 'nonexistant_function' member -E: 12: Module 'logilab.common.modutils' has no 'another' member -E: 13: Module 'logilab.common.modutils' has no 'yo' member -E: 17: Module 'sys' has no 'stdoout' member -E: 24: No name 'compiile' in module 're' -E: 24: No name 'findiiter' in module 're' -F: 6: Unable to import 'logilab.common.tutu' -F: 23: Unable to import 'rie' -W: 27: Statement seems to have no effect diff --git a/test/messages/func_unused_import_py30.txt b/test/messages/func_unused_import_py30.txt index 44f1ede..1868abc 100644 --- a/test/messages/func_unused_import_py30.txt +++ b/test/messages/func_unused_import_py30.txt @@ -1 +1 @@ -W: 8: Reimport 'ABCMeta' (imported line 7)
\ No newline at end of file +W: 8: Reimport 'ABCMeta' (imported line 7)
diff --git a/test/messages/func_w0231.txt b/test/messages/func_w0231.txt deleted file mode 100644 index ffde73e..0000000 --- a/test/messages/func_w0231.txt +++ /dev/null @@ -1,5 +0,0 @@ -C: 7:AAAA: Old-style class defined. -C: 13:BBBB: Old-style class defined. -C: 19:CCCC: Old-style class defined. -W: 26:ZZZZ.__init__: __init__ method from base class 'BBBB' is not called -W: 59:AssignedInit.__init__: __init__ method from base class 'NewStyleC' is not called diff --git a/test/messages/func_w0231_py30.txt b/test/messages/func_w0231_py30.txt deleted file mode 100644 index 0b06839..0000000 --- a/test/messages/func_w0231_py30.txt +++ /dev/null @@ -1,2 +0,0 @@ -W: 26:ZZZZ.__init__: __init__ method from base class 'BBBB' is not called -W: 59:AssignedInit.__init__: __init__ method from base class 'NewStyleC' is not called diff --git a/test/messages/func_with_used_before_assignment.txt b/test/messages/func_with_used_before_assignment.txt deleted file mode 100644 index dc6e386..0000000 --- a/test/messages/func_with_used_before_assignment.txt +++ /dev/null @@ -1,2 +0,0 @@ -E: 10:do_nothing: Undefined variable 'ctx'
-E: 11:do_nothing: Using variable 'context' before assignment
\ No newline at end of file diff --git a/test/messages/func_yield_outside_func.txt b/test/messages/func_yield_outside_func.txt deleted file mode 100644 index 3c74124..0000000 --- a/test/messages/func_yield_outside_func.txt +++ /dev/null @@ -1 +0,0 @@ -E: 3: Yield outside function |